public async Task <IActionResult> Authenticate([FromBody] AppUserAuthenticateCommandInputDTO input) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var identity = await GetClaimsIdentity(input.UserName, input.Password); if (identity == null) { return(BadRequest(Errors.AddErrorToModelState("login_failure", "Invalid username or password.", ModelState))); } var id = identity.Claims.Single(c => c.Type == "id").Value; return(await this.GenerateAuthenticationInfo(id)); } catch (Exception ex) { throw; } }
public OperationResponse <AppUserAuthenticateCommandOutputDTO> Execute(AppUserAuthenticateCommandInputDTO input) { using (var dbContextScope = this.DbContextScopeFactory.Create()) { return(this.Repository.Authenticate(input)); } }