public AuthResult ChangePassword(ChangePwdRequest changePwdRequest) { AuthResult authResult = null; try { int userId = ServiceHelper.CurrentUserId; authResult = AccountHandler.ChangePassword(userId, changePwdRequest.CurrentPwd, changePwdRequest.NewPassword); if (authResult.AuthStatus == AuthStatus.OK) { authResult = JWTHandler.CreateToken(authResult); } } catch (Exception ex) { Logger.LogException(ex); authResult.AuthStatus = AuthStatus.ERROR; } if (authResult.AuthStatus != AuthStatus.OK) { ServiceHelper.ThrowBadRequest <AuthResult>(Request, authResult); } return(authResult); }
public AuthResult Login(LoginRequest loginRequest) { AuthResult authResult = new AuthResult(); try { authResult = AccountHandler.Login(loginRequest); if (authResult.AuthStatus == AuthStatus.OK) { authResult = JWTHandler.CreateToken(authResult); } } catch (Exception ex) { Logger.LogException(ex); authResult.AuthStatus = AuthStatus.ERROR; } if (authResult.AuthStatus != AuthStatus.OK) { ServiceHelper.ThrowBadRequest <AuthResult>(Request, authResult); } return(authResult); }