public async Task <bool> SendPasswordlessLoginEmail(UserPasswordlessEmail loginEmail) { var emailTemplate = await GetEmailTemplate(Templates.PasswordlessLogin).ConfigureAwait(false); await SendTemplate(emailTemplate, loginEmail).ConfigureAwait(false); return(true); }
private async Task SendEmail(Core.Data.Entities.User user, string token) { var loginLink = Url.Page( "/Account/Link", pageHandler: null, values: new { token }, protocol: Request.Scheme); var model = new UserPasswordlessEmail { RecipientName = user.DisplayName, RecipientAddress = user.Email, Link = loginLink, ExpireHours = (int)_securityOptions.Value.PasswordlessTokenLifespan.TotalHours }; Request.ReadUserAgent(model); var result = await _templateService.SendPasswordlessLoginEmail(model); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } var user = await _userManager.FindByEmailAsync(Input.Email); if (user == null) { ModelState.AddModelError("Input.Email", "Email address not registered."); return(Page()); } var token = await _userManager.GenerateUserTokenAsync( user, PasswordlessLoginToken.ProviderName, PasswordlessLoginToken.TokenPurpose); var loginLink = Url.Page( "/Account/LoginCallback", pageHandler: null, values: new { id = user.Id, token, returnUrl = ReturnUrl }, protocol: Request.Scheme); var userAgent = Request.UserAgent(); var model = new UserPasswordlessEmail { DisplayName = user.DisplayName, EmailAddress = user.Email, LoginLink = loginLink, UserAgent = userAgent }; var result = await _templateService.SendPasswordlessLoginEmail(model); return(RedirectToPage("./PasswordlessConfirmation")); }