Beispiel #1
0
        public static async Task SendPasswordResetEmail(this ApplicationUserManager userManager, UserViewModel user, EmailTemplate emailTemplate = EmailTemplate.ResetPassword, string subject = "MBOS : Password reset")
        {
            var code = await userManager.GeneratePasswordResetTokenAsync(user.Id);

            NameValueCollection nvc = new NameValueCollection()
            {
                { "code", code }, { "userid", GeneralService.EncryptText(user.Id.ToString()) }
            };
            EmailRequestWithUrl <UserViewModel> model = new EmailRequestWithUrl <UserViewModel>()
            {
                Url   = GeneralHelper.BuildUrl("/resetpassword", nvc),
                Model = user
            };
            var mailBody = userManager.EmailComposer.GetMailContent(model, emailTemplate);
            await userManager.SendEmailAsync(user.Id, subject, mailBody);
        }