public async Task EmailConfirmation(Account targetUser) { var uri = await _auth.GenerateEmailConfirmationTokenLinkAsync(targetUser, _settings.EmailConfirmation); var targetUserNotification = await CreateNotification(targetUser); var activationNotification = new EmailConfirmationNotification(targetUserNotification, uri.ToString()); await _repository.SendEmailConfirmationNotification(activationNotification); }
public async Task <ActionResult> Register([FromForm] UserRegistration registration) { TryValidateModel(registration); if (ModelState.IsValid) { //Register user var user = registration.ToUser(); user.Contact = registration.ToContact(); user.StoreId = WorkContext.CurrentStore.Id; var result = await _signInManager.UserManager.CreateAsync(user, registration.Password); if (result.Succeeded) { user = await _signInManager.UserManager.FindByNameAsync(user.UserName); await _publisher.Publish(new UserRegisteredEvent(WorkContext, user, registration)); await _signInManager.SignInAsync(user, isPersistent : true); await _publisher.Publish(new UserLoginEvent(WorkContext, user)); if (_options.SendAccountConfirmation) { var token = await _signInManager.UserManager.GenerateEmailConfirmationTokenAsync(user); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { UserId = user.Id, Token = token }, protocol: Request.Scheme); var emailConfirmationNotification = new EmailConfirmationNotification(WorkContext.CurrentStore.Id, WorkContext.CurrentLanguage) { Url = callbackUrl, Sender = WorkContext.CurrentStore.Email, Recipient = GetUserEmail(user) }; await _platformNotificationApi.SendNotificationAsync(emailConfirmationNotification.ToNotificationDto()); } return(StoreFrontRedirect("~/account")); } else { foreach (var error in result.Errors) { ModelState.AddModelError("form", error.Description); } } } WorkContext.Form = registration; return(View("customers/register", WorkContext)); }
public async Task <ActionResult> Register([FromForm] UserRegistration registration) { TryValidateModel(registration); // This required for populate fields on form on post-back WorkContext.Form = Form.FromObject(registration); if (ModelState.IsValid) { // Register user var user = registration.ToUser(); user.Contact = registration.ToContact(); user.StoreId = WorkContext.CurrentStore.Id; var result = await _signInManager.UserManager.CreateAsync(user, registration.Password); if (result.Succeeded) { user = await _signInManager.UserManager.FindByNameAsync(user.UserName); await _publisher.Publish(new UserRegisteredEvent(WorkContext, user, registration)); if (!_identityOptions.SignIn.RequireConfirmedEmail) { await _signInManager.SignInAsync(user, isPersistent : true); await _publisher.Publish(new UserLoginEvent(WorkContext, user)); } // Send new user registration notification var registrationEmailNotification = new RegistrationEmailNotification(WorkContext.CurrentStore.Id, WorkContext.CurrentLanguage) { FirstName = registration.FirstName, LastName = registration.LastName, Login = registration.UserName, Sender = WorkContext.CurrentStore.Email, Recipient = GetUserEmail(user) }; await SendNotificationAsync(registrationEmailNotification); if (_options.SendAccountConfirmation) { var token = await _signInManager.UserManager.GenerateEmailConfirmationTokenAsync(user); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { UserId = user.Id, Token = token }, protocol: Request.Scheme, host: WorkContext.CurrentStore.Host); var emailConfirmationNotification = new EmailConfirmationNotification(WorkContext.CurrentStore.Id, WorkContext.CurrentLanguage) { Url = callbackUrl, Sender = WorkContext.CurrentStore.Email, Recipient = GetUserEmail(user) }; var sendNotifcationResult = await SendNotificationAsync(emailConfirmationNotification); if (sendNotifcationResult.IsSuccess == false) { WorkContext.Form.Errors.Add(SecurityErrorDescriber.ErrorSendNotification(sendNotifcationResult.ErrorMessage)); return(View("customers/register", WorkContext)); } } return(StoreFrontRedirect("~/account")); } else { foreach (var error in result.Errors) { WorkContext.Form.Errors.Add(new FormError { Code = error.Code?.PascalToKebabCase(), Description = error.Description }); } } } return(View("customers/register", WorkContext)); }
internal static void eSignEmailConfirmationNotification(string language, Notification notification) { notification = new EmailConfirmationNotification(notification, "https://sodapdf.com/"); Send(language, EmailTemplate.eSignEmailConfirmationNotification, notification); }
public async Task SendEmailConfirmationNotification(EmailConfirmationNotification model) { await EmailInsert(model.AccountId, EmailTemplate.EmailConfirmationNotification, model.Email, model); }