public async Task <IActionResult> Index(LoginModel model) { if (ModelState.IsValid) { await _signInManager.PasswordlessSignInAsync(model.Email, Url.Action("Confirm", "Login", null, Request.Scheme)); return(RedirectToAction("Index", "Home")); } return(View(model)); }
public async Task <IActionResult> Index(PasswordlessLoginModel model, string button) { var context = await _interaction.GetAuthorizationContextAsync(model.ReturnUrl); if (ModelState.IsValid) { var result = await _signInManager.PasswordlessSignInAsync(model.Email, model.ReturnUrl); if (result.Succeeded) { var user = await _userManager.FindByNameAsync(model.Email); // var claims = _userManager.AddClaimsAsync(user, new Claim[]{ // new Claim(JwtClaimTypes.Name, "Alice Smith"), // new Claim(JwtClaimTypes.GivenName, "Alice"), // new Claim(JwtClaimTypes.FamilyName, "Smith"), // new Claim(JwtClaimTypes.Email, "*****@*****.**"), // new Claim(JwtClaimTypes.EmailVerified, "true", ClaimValueTypes.Boolean), // new Claim(JwtClaimTypes.WebSite, "http://alice.com"), // new Claim(JwtClaimTypes.Address, @"{ 'street_address': 'One Hacker Way', 'locality': 'Heidelberg', 'postal_code': 69118, 'country': 'Germany' }", IdentityServer4.IdentityServerConstants.ClaimValueTypes.Json) // }).Result; var validate = _signInManager.PasswordlessSignInAsync(user, true, lockoutOnFailure: true); await _events.RaiseAsync(new UserLoginSuccessEvent(user.Email, user.Id, user.Email)); // request for a local page if (Url.IsLocalUrl(model.ReturnUrl)) { return(Redirect(model.ReturnUrl)); } else if (string.IsNullOrEmpty(model.ReturnUrl)) { return(Redirect("~/")); } else { // user might have clicked on a malicious link - should be logged throw new Exception("invalid return URL"); } } await _events.RaiseAsync(new UserLoginFailureEvent(model.Email, "Invalid Email Address")); ModelState.AddModelError(string.Empty, AccountOptions.InvalidCredentialsErrorMessage); } return(RedirectToAction("Index", new { error = "Something went wrong - 01" })); }
public async Task <IActionResult> Index(LoginModel model) { if (ModelState.IsValid) { await _signInManager.PasswordlessSignInAsync(model.Email, model.ReturnUrl); return(RedirectToAction("Index", new { success = 3 })); } return(View(model)); }
public async Task <IActionResult> Index(LoginModel model) { if (ModelState.IsValid) { await _passwordlessSignInManager.PasswordlessSignInAsync(model.Email, model.ReturnUrl); return(RedirectToAction("Index", new { success = "If a valid admin user with this email address exists, " + "we've sent you an email with a secure link to log in." })); } return(View(model)); }
public async Task <IActionResult> Index(LoginModel model) { if (ModelState.IsValid) { var result = await _signInManager.PasswordlessSignInAsync(model.Email); if (result.Succeeded) { return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError(string.Empty, "Account not found."); } } return(View(model)); }