コード例 #1
0
        public IActionResult GetToken(UserModel userModel)
        {
            try
            {
                if (UserSettings.ValidateUser(_configuration, userModel.User, userModel.Password))
                {
                    return(Ok(JwtConfiguration.GenerateJwtToken(_appSettings)));
                }

                return(NotFound("Invalid username or password"));
            }
            catch (Exception ex)
            {
                return(InternalServerErrorResponse(ex));
            }
        }
コード例 #2
0
ファイル: AuthController.cs プロジェクト: BrunoTragl/test-c
        public IActionResult GetToken(UserModel userModel)
        {
            try
            {
                if (UserSetting.ValidateUser(_configuration, userModel.User, userModel.Password))
                {
                    return(Ok(JwtConfiguration.GenerateJwtToken(_appSetting)));
                }

                return(NotFound(new
                {
                    error = "Invalid username or password",
                    requested = DateTime.UtcNow
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerErrorResponse(Resources.Auth, ex));
            }
        }