public LoginAccountModel.Response Login([FromBody] LoginAccountModel res) { var user = _accountService.SignIn(res.Email, res.Password); if (user != null) { var token = _authenticator.GetToken(user, DateTime.UtcNow.AddYears(1)); return(new LoginAccountModel.Response { Token = token, Id = user.Id }); } //TODO Gestion d'erreur return(null); }
public async Task <ActionResult <LoggedInUserModel> > Login([FromBody] LoginAccountModel account) { var user = await _userManager.FindByEmailAsync(account.Email); if (user == null) { return(null); } var signInResult = await _signInManager.PasswordSignInAsync(user, account.Password, isPersistent : true, lockoutOnFailure : false); //lockout on failure is off because this is a demo if (!signInResult.Succeeded) { return(null); } return(new LoggedInUserModel { UserId = user.Id, Username = user.UserName, LibraryId = user.LibraryId }); }
public void OnGet(string returnUrl) { Input = new LoginAccountModel(); Input.ReturnUrl = returnUrl; }