public virtual ActionResult ConfirmationRequiredPost() { User user = GetCurrentUser(); var confirmationUrl = Url.ConfirmationUrl( "Confirm", "Users", user.Username, user.EmailConfirmationToken); var alreadyConfirmed = user.UnconfirmedEmailAddress == null; ConfirmationViewModel model; if (!alreadyConfirmed) { MessageService.SendNewAccountEmail(new MailAddress(user.UnconfirmedEmailAddress, user.Username), confirmationUrl); model = new ConfirmationViewModel { ConfirmingNewAccount = !(user.Confirmed), UnconfirmedEmailAddress = user.UnconfirmedEmailAddress, SentEmail = true, }; } else { model = new ConfirmationViewModel { AlreadyConfirmed = true }; } return(View(model)); }
public virtual ActionResult ConfirmationRequiredPost() { User user = GetCurrentUser(); var confirmationUrl = Url.ConfirmationUrl( "Confirm", "Users", user.Username, user.EmailConfirmationToken); var alreadyConfirmed = user.UnconfirmedEmailAddress == null; ConfirmationViewModel model; if (!alreadyConfirmed) { MessageService.SendNewAccountEmail(new MailAddress(user.UnconfirmedEmailAddress, user.Username), confirmationUrl); model = new ConfirmationViewModel { ConfirmingNewAccount = !(user.Confirmed), UnconfirmedEmailAddress = user.UnconfirmedEmailAddress, SentEmail = true, }; } else { model = new ConfirmationViewModel {AlreadyConfirmed = true}; } return View(model); }
public virtual async Task <ActionResult> ConfirmationRequiredPost(string accountName = null) { var account = GetAccount(accountName); if (account == null || ActionsRequiringPermissions.ManageAccount.CheckPermissions(GetCurrentUser(), account) != PermissionsCheckResult.Allowed) { return(new HttpStatusCodeResult(HttpStatusCode.Forbidden, Strings.Unauthorized)); } var alreadyConfirmed = account.UnconfirmedEmailAddress == null; ConfirmationViewModel model; if (!alreadyConfirmed) { await SendNewAccountEmailAsync(account); model = new ConfirmationViewModel(account) { SentEmail = true }; } else { model = new ConfirmationViewModel(account); } return(View(model)); }
public virtual async Task <ActionResult> Confirm(string username, string token) { // We don't want Login to have us as a return URL // By having this value present in the dictionary BUT null, we don't put "returnUrl" on the Login link at all ViewData[Constants.ReturnUrlViewDataKey] = null; if (!String.Equals(username, User.Identity.Name, StringComparison.OrdinalIgnoreCase)) { return(View(new ConfirmationViewModel { WrongUsername = true, SuccessfulConfirmation = false, })); } var user = GetCurrentUser(); var alreadyConfirmed = user.UnconfirmedEmailAddress == null; string existingEmail = user.EmailAddress; var model = new ConfirmationViewModel { ConfirmingNewAccount = String.IsNullOrEmpty(existingEmail), SuccessfulConfirmation = !alreadyConfirmed, AlreadyConfirmed = alreadyConfirmed }; if (!alreadyConfirmed) { try { if (!(await UserService.ConfirmEmailAddress(user, token))) { model.SuccessfulConfirmation = false; } } catch (EntityException) { model.SuccessfulConfirmation = false; model.DuplicateEmailAddress = true; } // SuccessfulConfirmation is required so that the confirm Action isn't a way to spam people. // Change notice not required for new accounts. if (model.SuccessfulConfirmation && !model.ConfirmingNewAccount) { MessageService.SendEmailChangeNoticeToPreviousEmailAddress(user, existingEmail); string returnUrl = HttpContext.GetConfirmationReturnUrl(); if (!String.IsNullOrEmpty(returnUrl)) { TempData["Message"] = "You have successfully confirmed your email address!"; return(SafeRedirect(returnUrl)); } } } return(View(model)); }
public virtual ActionResult ConfirmationRequired() { User user = GetCurrentUser(); var model = new ConfirmationViewModel { ConfirmingNewAccount = !(user.Confirmed), UnconfirmedEmailAddress = user.UnconfirmedEmailAddress, }; return View(model); }
public virtual ActionResult ConfirmationRequired() { User user = UserService.FindByUsername(User.Identity.Name); var model = new ConfirmationViewModel { ConfirmingNewAccount = !(user.Confirmed), UnconfirmedEmailAddress = user.UnconfirmedEmailAddress, }; return View(model); }
public virtual ActionResult ConfirmationRequired() { User user = GetCurrentUser(); var model = new ConfirmationViewModel { ConfirmingNewAccount = !(user.Confirmed), UnconfirmedEmailAddress = user.UnconfirmedEmailAddress, }; return(View(model)); }
public virtual ActionResult ConfirmationRequired() { User user = UserService.FindByUsername(User.Identity.Name); var model = new ConfirmationViewModel { ConfirmingNewAccount = !(user.Confirmed), UnconfirmedEmailAddress = user.UnconfirmedEmailAddress, }; return(View(model)); }
public virtual async Task <ActionResult> Confirm(string accountName, string token) { // We don't want Login to go to this page as a return URL // By having this value present in the dictionary BUT null, we don't put "returnUrl" on the Login link at all ViewData[GalleryConstants.ReturnUrlViewDataKey] = null; var account = GetAccount(accountName); if (account == null || ActionsRequiringPermissions.ManageAccount.CheckPermissions(GetCurrentUser(), account) != PermissionsCheckResult.Allowed) { return(View(new ConfirmationViewModel(accountName) { WrongUsername = true, SuccessfulConfirmation = false })); } string existingEmail = account.EmailAddress; var model = new ConfirmationViewModel(account); if (!model.AlreadyConfirmed) { try { model.SuccessfulConfirmation = await UserService.ConfirmEmailAddress(account, token); } catch (EntityException) { model.SuccessfulConfirmation = false; model.DuplicateEmailAddress = true; } // SuccessfulConfirmation is required so that the confirm Action isn't a way to spam people. // Change notice not required for new accounts. if (model.SuccessfulConfirmation && !model.ConfirmingNewAccount) { var message = new EmailChangeNoticeToPreviousEmailAddressMessage(MessageServiceConfiguration, account, existingEmail); await MessageService.SendMessageAsync(message); string returnUrl = HttpContext.GetConfirmationReturnUrl(); if (!String.IsNullOrEmpty(returnUrl)) { TempData["Message"] = Messages.EmailConfirmed; return(SafeRedirect(returnUrl)); } } } return(View(model)); }
public virtual ActionResult ConfirmationRequired(string accountName = null) { var account = GetAccount(accountName); if (account == null || ActionsRequiringPermissions.ManageAccount.CheckPermissions(GetCurrentUser(), account) != PermissionsCheckResult.Allowed) { return(new HttpStatusCodeResult(HttpStatusCode.Forbidden, Strings.Unauthorized)); } var model = new ConfirmationViewModel(account); return(View(model)); }
public virtual ActionResult ConfirmationRequiredPost() { User user = UserService.FindByUsername(User.Identity.Name); var confirmationUrl = Url.ConfirmationUrl( MVC.Users.Confirm(), user.Username, user.EmailConfirmationToken, protocol: Request.Url.Scheme); MessageService.SendNewAccountEmail(new MailAddress(user.UnconfirmedEmailAddress, user.Username), confirmationUrl); var model = new ConfirmationViewModel { ConfirmingNewAccount = !(user.Confirmed), UnconfirmedEmailAddress = user.UnconfirmedEmailAddress, SentEmail = true, }; return View(model); }
public virtual ActionResult ConfirmationRequiredPost() { User user = UserService.FindByUsername(User.Identity.Name); var confirmationUrl = Url.ConfirmationUrl( MVC.Users.Confirm(), user.Username, user.EmailConfirmationToken, protocol: Request.Url.Scheme); MessageService.SendNewAccountEmail(new MailAddress(user.UnconfirmedEmailAddress, user.Username), confirmationUrl); var model = new ConfirmationViewModel { ConfirmingNewAccount = !(user.Confirmed), UnconfirmedEmailAddress = user.UnconfirmedEmailAddress, SentEmail = true, }; return(View(model)); }
public virtual ActionResult ConfirmationRequiredPost() { User user = GetCurrentUser(); var confirmationUrl = Url.ConfirmEmail(user.Username, user.EmailConfirmationToken, relativeUrl: false); var alreadyConfirmed = user.UnconfirmedEmailAddress == null; ConfirmationViewModel model; if (!alreadyConfirmed) { _messageService.SendNewAccountEmail(new MailAddress(user.UnconfirmedEmailAddress, user.Username), confirmationUrl); model = new ConfirmationViewModel(user) { SentEmail = true }; } else { model = new ConfirmationViewModel(user); } return(View(model)); }
public virtual async Task<ActionResult> Confirm(string username, string token) { // We don't want Login to have us as a return URL // By having this value present in the dictionary BUT null, we don't put "returnUrl" on the Login link at all ViewData[Constants.ReturnUrlViewDataKey] = null; if (!String.Equals(username, User.Identity.Name, StringComparison.OrdinalIgnoreCase)) { return View(new ConfirmationViewModel { WrongUsername = true, SuccessfulConfirmation = false, }); } var user = GetCurrentUser(); var alreadyConfirmed = user.UnconfirmedEmailAddress == null; string existingEmail = user.EmailAddress; var model = new ConfirmationViewModel { ConfirmingNewAccount = String.IsNullOrEmpty(existingEmail), SuccessfulConfirmation = !alreadyConfirmed, AlreadyConfirmed = alreadyConfirmed }; if (!alreadyConfirmed) { try { if (!(await UserService.ConfirmEmailAddress(user, token))) { model.SuccessfulConfirmation = false; } } catch (EntityException) { model.SuccessfulConfirmation = false; model.DuplicateEmailAddress = true; } // SuccessfulConfirmation is required so that the confirm Action isn't a way to spam people. // Change notice not required for new accounts. if (model.SuccessfulConfirmation && !model.ConfirmingNewAccount) { MessageService.SendEmailChangeNoticeToPreviousEmailAddress(user, existingEmail); string returnUrl = HttpContext.GetConfirmationReturnUrl(); if (!String.IsNullOrEmpty(returnUrl)) { TempData["Message"] = "You have successfully confirmed your email address!"; return SafeRedirect(returnUrl); } } } return View(model); }
public virtual ActionResult ConfirmationRequired() { var model = new ConfirmationViewModel(GetCurrentUser()); return(View(model)); }