Beispiel #1
0
        /// <summary>
        /// Sends the Confirmation Email
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public ActionResult SendConfirmationEmail(UserBaseViewModel model)
        {
            if (ModelState.IsValid && model.UserId != null)
            {
                JSUser user = JSUserBusinessManager.Current.UserManager.FindById(model.UserId ?? 0);

                string confirmationToken = JSUserBusinessManager.Current.UserManager.GenerateEmailConfirmationToken(model.UserId ?? 0);

                ConfirmationTokenModel emailModel = new ConfirmationTokenModel()
                {
                    User = user,
                    ConfirmationToken = confirmationToken
                };

                EmailHelper.Current.Send(EmailTypes.ConfirmEmail, emailModel, new List <string>()
                {
                    user.Email
                });

                AppMessenger.Current.Send(MessageTypes.ConfirmationEmailSent,
                                          String.Format("{0} has sent a confirmation email to his/her email account ({1})", user.UserName, user.Email),
                                          "A confirmation email has been sent.");

                ViewBag.ConfirmationEmailSent = true;
            }

            return(Manage());
        }
Beispiel #2
0
        public async Task <ActionResult> ForgotPassword(ForgotPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                JSUser user = await JSUserBusinessManager.Current.UserManager.FindByEmailAsync(model.Email);

                if (user == null || !(await JSUserBusinessManager.Current.UserManager.IsEmailConfirmedAsync(user.Id)))
                {
                    ModelState.AddModelError("", Localization.TheUserEitherDoesNotExistOrIsNotConfirmed);
                    return(View());
                }

                string confirmationToken = JSUserBusinessManager.Current.UserManager.GeneratePasswordResetToken(user.JSUserId);

                ConfirmationTokenModel emailModel = new ConfirmationTokenModel()
                {
                    User = user,
                    ConfirmationToken = confirmationToken
                };

                EmailHelper.Current.Send(EmailTypes.ResetPassword, emailModel, new List <string>()
                {
                    user.Email
                });

                await AppMessenger.Current.Send(MessageTypes.PasswordResetEmailSent,
                                                String.Format("{0} has sent a password reset email to his/her email account ({1})", user.UserName, user.Email),
                                                "A password reset email has been sent.");

                ViewBag.StatusMessage = Localization.PleaseCheckYourEmailToResetYourPassword;
                return(View(model));
            }
            return(View(model));
        }