public IAuthenticationToken GetToken(string username, string password) { if (_authenticator.Authenticate(username, password) == false) { return(new AuthenticationToken { Username = username }); } return(_repository.RetrieveByUsername(username)); }
protected override async Task Handle(IExecutionContextReader context, RegisterUser request) { var id = await _userService.Create(request); await _emailSender.SendAsync(request); await _authenticator.Authenticate(new UserAuthRequest { Email = request.Email, Id = id }); }
public bool SignIn(string username, string password, bool rememberMe) { var authenticated = _agentAuthenticator.Authenticate(username, password); if (!authenticated) { return(false); } _formsAuthentication.SetAuthCookie(username, rememberMe); return(true); }
public bool SignIn(string username, string password, bool rememberMe) { var authenticated = _agentAuthenticator.Authenticate(username, password); if (!authenticated) { return(false); } var identity = new GenericIdentity(username); _currentSdkUser.SetUser(_principalFactory.CreatePrincipal(identity)); _formsAuthentication.SetAuthCookie(username, rememberMe); return(true); }
async Task <IResponse> IRequestHandlerAsync <LoginRequest> .Handle(IExecutionContextReader context, LoginRequest request) { var user = await _userService.Retrieve(request); if (user == null) { return(FailedResponse()); } await _authenticator.Authenticate(new UserAuthRequest { Id = user.Id, Email = user.Email }); return(Response.Succeed()); }
public IActionResult Authenticate([FromBody] AuthUserModel authUser) { User user = userAuthenticator.Authenticate(authUser.Name, authUser.Password); if (user == null) { return(BadRequest(new { message = "Bad username or password" })); } string token = JWTGenerator.GetToken("cQfTjWnZr4u7x!z%", user.ID.ToString()); return(Ok(new { ID = user.ID, Username = user.Name, Token = token })); }
public ActionResult LogOn(AuthenticationModel credentials, string returnUrl) { try { var user = _userAuthenticator.Authenticate(credentials.UserName, credentials.Password); var webUser = WebUser.Create(user); GenerateAndStoreCookies(webUser); UserSession.Current = webUser; return(!string.IsNullOrEmpty(returnUrl) ? (ActionResult)Redirect(returnUrl) : RedirectToAction("Index", "Dashboard")); } catch (UserAuthenticationException authFailure) { credentials.AuthenticationError = authFailure.FailureReason.ToString(); return(View(credentials)); } }
public bool SignIn(string username, string password, bool rememberMe) { _logger.LogDebug("Authenticating session {0}.".ToFormat(username)); var isAuthenticated = _agentAuthenticator.Authenticate(username, password); if (!isAuthenticated) { return(false); } _impersonationService.StopImpersonating(username); _currentSdkUser.SetUser(username); _formsAuthentication.SetAuthCookie(username, rememberMe); return(true); }
public async Task <UserData> HandleAsync(AuthenticateUser query) { var user = await userAuthenticator.Authenticate(query); return(user.ToContract()); }
public async Task <ActionResult <IUserAuthenticationResult> > GetToken([FromBody] LoginInformation login) { var authResult = await authenticator.Authenticate(login.Username, login.Password); return(Ok(authResult)); }