Beispiel #1
0
        public async Task <(IdentityResult Result, JwtToken Token)> Login(string username, string password)
        {
            var user = await _manager.FindByNameAsync(username);

            var isChecked = await _manager.CheckPasswordAsync(user, password);

            if (user == null || !isChecked)
            {
                throw new UnauthorizedAccessException();
            }

            return(IdentityResult.Success(), new JwtToken {
                Value = CreateToken(user)
            });
        }