public async Task SendVerifyEmailEmailAsync(string email, Guid userId, string token) { var message = CreateDefaultMessage("Verify Your Email", email); var model = new VerifyEmailModel { Token = WebUtility.UrlEncode(token), UserId = userId, WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash, SiteName = _globalSettings.SiteName }; await AddMessageContentAsync(message, "VerifyEmail", model); message.MetaData.Add("SendGridBypassListManagement", true); message.MetaData.Add("SendGridCategories", new List <string> { "VerifyEmail" }); await _mailDeliveryService.SendEmailAsync(message); }
public async Task <IHttpActionResult> VerifyEmail(VerifyEmailModel model) { if (model.UserId == null || model.Code == null) { return(ErrorApiResult(1, "Нет параметров")); } var userId = long.Parse(model.UserId); IdentityResult result = await _userManager.ConfirmEmailAsync(userId, model.Code); if (result.Succeeded) { return(EmptyApiResult()); } else { var errorsMessages = ModelState.Values.SelectMany(v => v.Errors.Select(b => b.ErrorMessage)); return(ErrorApiResult(1, errorsMessages)); } }
public async Task SendVerifyEmailEmailAsync(string email, Guid userId, string token) { var message = CreateDefaultMessage("Verify Your Email", email); var model = new VerifyEmailModel { Token = WebUtility.UrlEncode(token), UserId = userId, WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash, SiteName = _globalSettings.SiteName }; message.HtmlContent = await _engine.CompileRenderAsync("VerifyEmail", model); message.TextContent = await _engine.CompileRenderAsync("VerifyEmail.text", model); message.MetaData.Add("SendGridBypassListManagement", true); await _mailDeliveryService.SendEmailAsync(message); }
public ActionResult VerifyEmail(string id, string token) { EmailVerifier userToken = _factory.CreateEmailVerifierDao().Get(id); try { if (userToken == null) { return(View("~/Views/HttpErrors/404.cshtml")); } var verifyEmailModel = new VerifyEmailModel(userToken); return(View(verifyEmailModel.Verify(OrnamentContext.MemberShip.CurrentUser(), token, _factory))); } finally { if (userToken != null) { _factory.CreateEmailVerifierDao().SaveOrUpdate(userToken); } } }
public async Task <IActionResult> NeedVerification(VerifyEmailModel model) { if (ModelState.IsValid) { UserModel user = await _userManager.FindByEmailAsync(model.Email); if (user != null) { if (Equals(user.EmailVerificationKey, model.VerificationKey)) { user.EmailConfirmed = true; await _userManager.UpdateAsync(user); await _signInManager.SignOutAsync(); Microsoft.AspNetCore.Identity.SignInResult result = await _signInManager.PasswordSignInAsync(user, model.Password, false, false); if (result.Succeeded) { await _userManager.AddToRoleAsync(user, _configuration["DefaultRoleName"]); return(RedirectToAction("Index", "Home")); } } else { ModelState.AddModelError("", ApplicationResources.UserInterface.Common.VerificationKeyDoesNotMatch); } } else { ModelState.AddModelError("", ApplicationResources.UserInterface.Common.UserDoNotExist); } } return(View(model)); }
public async Task <string> VerifyEmail(string Token) { using var httpClient = new HttpClient(); using var request = new HttpRequestMessage(new HttpMethod("POST"), VerifyEmailRequestUri); VerifyEmailModel verifyEmailModel = new VerifyEmailModel() { IdToken = Token, RequestType = "VERIFY_EMAIL" }; string s1 = JsonConvert.SerializeObject(verifyEmailModel); request.Content = new StringContent(s1); request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json"); var response = await httpClient.SendAsync(request); if (response.IsSuccessStatusCode) { return("OK"); } else { return("Error"); } }
public string VerifyEmail([FromBody] VerifyEmailModel verifyEmailModel) { SignupDetails signupDetails = new SignupDetails(); return(signupDetails.VerifyEmail(verifyEmailModel)); }
public bool VerifyEmail(VerifyEmailModel model) { model.Send(_factory); return(true); }
public IActionResult VerifyEmail([FromBody] VerifyEmailModel model) { _userService.VerifyEmail(model.Token); return(Ok(new { message = "✓ Verification Success, You Can Now Login!" })); }
private string generateEmailBody(string template, VerifyEmailModel model) { try { return Razor.Parse(template, model); } catch (Exception e) { logAccessor.CreateLog(DateTime.Now, this.GetType().ToString() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), e.ToString()); return e.Message; } }
public bool SendVerificationMail(Guid guid, string name, string email) { try { string newString = HttpContext.Current.Request.Url.Authority.ToString(); string guidstring = guid.ToString(); VerifyEmailModel verifyEmailModel = new VerifyEmailModel() { Name = name, GuidString = guid.ToString(), ClientUrl = "http://" + HttpContext.Current.Request.Url.Authority.ToString() }; String messageBody = generateEmailBody(Manager.Properties.Resources.VerifyEmailTemplate.ToString(), verifyEmailModel); SendMessage("*****@*****.**", "Vestn", new String[1] { email }, null, null, "Verify Your Email to Create Your Vestn Account!", messageBody); return true; } catch (Exception ex) { logAccessor.CreateLog(DateTime.Now, this.GetType().ToString() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), ex.ToString()); return false; } }
private void DoLogin(object parameter) { LoginModel loginModel; if (!IsFormValid(parameter, out loginModel)) { return; } MainVm.LoggedIn = false; Loading = true; ErrorMessage = ""; Task.Run(async() => { try { // Verify email first if (ShowConfirmEmail) { var model = new VerifyEmailModel(Email, EmailToken); await _userClient.VerifyEmail(model); } await _userClient.LoginAsync(loginModel.Email, loginModel.Password); var details = await _userClient.GetCurrentUserDetails(); MainVm.Login(this, details); ShowConfirmEmail = false; Loading = false; Email = ""; } catch (IncorrectLoginException) { Ui(() => { ErrorMessage = "Invalid Username or Password"; Loading = false; }); } catch (EmailVerificationNeededException) { Ui(() => { ShowConfirmEmail = true; ErrorMessage = "This email is unconfirmed. Please enter the verification token sent to this email."; Loading = false; }); } catch (UnauthorizedException) { Ui(() => { ErrorMessage = "Invalid Token"; Loading = false; }); } catch (ApiException e) { Ui(() => { ErrorMessage = "An Unknown Error Occurred"; Loading = false; }); } }); }
public VerifyEmailRequestModel(VerifyEmailModel model) { Email = model.Email; Code = model.Token; }
public async Task VerifyEmail(VerifyEmailModel verifyEmailModel) { var requestModel = new VerifyEmailRequestModel(verifyEmailModel); await PostAsync(Resources.VerifyEmailAction, requestModel); }
public async Task <IdentityResult> VerifyEmail(VerifyEmailModel user) { return(await _userManager.ConfirmEmailAsync(user.UserId, user.Token)); }