using Microsoft.AspNetCore.Components; using System.ComponentModel.DataAnnotations; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Cookies; using TestApp02.Data; using Microsoft.AspNetCore.Mvc.ModelBinding; using System.Security.Claims; using Microsoft.AspNetCore.Authentication.Cookies; using System.Web; namespace TestApp02.Pages { public class LoginModel: ComponentBase { [Inject] NavigationManager _navigationManager { get; set; } //private BiudAuthService _BiudAuthService; [Inject] BiudAuthService _BiudAuthService { get; set; } //public LoginModel(BiudAuthService pBiudAuthService) public LoginModel() { loginAccountForm= new LoginAccountForm(); } public LoginAccountForm loginAccountForm { get; set;} protected async Task OnPostAsync() { //ClaimsPrincipal principal; //principal = _BiudAuthService.AuthenticateUser(loginAccountForm.Username, loginAccountForm.Password); //if (principal == null) { // //await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal); //}; //var identity = principal.Identity as ClaimsIdentity; string _uName = encode(loginAccountForm.Username); string _uPass = encode(loginAccountForm.Password); _navigationManager.NavigateTo("/login?paramUsername="+ _uName + "¶mPassword=" + _uPass, true); } private string encode(string param) { return HttpUtility.UrlEncode(param); } } public class LoginAccountForm { [Required (ErrorMessage = "Необходим логин")] [StringLength(30, ErrorMessage = "Допустимая длина логина от 3 до 30 символов ", MinimumLength = 3)] public string Username { get; set; } [Required(ErrorMessage = "Необходим пароль")] [StringLength(30, ErrorMessage = "Допустимая длина пароля от 3 до 30 символов ", MinimumLength = 3)] public string Password { get; set; } } }