private async ValueTask <ClaimsIdentity> GetIdentity(string login, string password) { DataWrapper <AuthorizationDto> authorizationDto = await _repo.GetByLogin(login); PasswordEncryptor encryptor = new PasswordEncryptor(); if (authorizationDto.Data != null) { if (encryptor.CheckPassword(authorizationDto.Data.Password, password)) { List <Claim> claims = new List <Claim>() { new Claim(ClaimsIdentity.DefaultNameClaimType, authorizationDto.Data.Login), new Claim(ClaimsIdentity.DefaultRoleClaimType, authorizationDto.Data.Role.Name) }; ClaimsIdentity claimsIdentity = new ClaimsIdentity(claims, "Token", ClaimsIdentity.DefaultNameClaimType, ClaimsIdentity.DefaultRoleClaimType); return(claimsIdentity); } else { return(null); } } return(null); }