public async Task <IActionResult> Authenticate([FromBody] AutUserForAuthenticationDto autUser)
        {
            if (!await _authManager.ValidateUser(autUser))
            {
                _logger.LogWarn($"{nameof(Authenticate)}: Authentication failed. Wrong user name or password.");
                return(Unauthorized());
            }

            return(Ok(new { Token = await _authManager.CreateToken() }));
        }
示例#2
0
        public async Task <bool> ValidateUser(AutUserForAuthenticationDto userForAuth)
        {
            _user = await _userManager.FindByNameAsync(userForAuth.UserName);

            return(_user != null && await _userManager.CheckPasswordAsync(_user, userForAuth.Password));
        }