Beispiel #1
0
        public ActionResult ResetPassword(string email)
        {
            var user = _dbhelper.GetUserByEmail(new WritaUser()
            {
                EmailAddress = email
            });

            if (user != null)
            {
                var    newpass        = CreateRandomPassword(12);
                var    newEncpassword = BCrypt.Net.BCrypt.HashPassword(newpass, 13);
                string subject        = "Your Writa Password Reset";
                string body           = "Your new writa password is " + newpass;
                user.UserPasswordEncrypted = newEncpassword;
                try
                {
                    _email.SendEmail(subject, body, email, _globalsettings.LoadSettings().EmailFromAddress);
                    _dbhelper.UpdateUser(user);
                    ViewBag.Sent = true;
                }
                catch (SmtpException e)
                {
                    ViewBag.Sent  = false;
                    ViewBag.Error = true;
                }
            }
            else
            {
                ViewBag.Error = true;
            }
            return(View("~/Views/Admin/ResetPassword.cshtml", "~/Views/Admin/_Adminlayout.cshtml"));
        }
Beispiel #2
0
 public MailReturnValue SendEmail(string fromMail, string mailSubject, string mailBody, bool isBodyHTML, string toMail)
 {
     return(emailSend.SendEmail(fromMail, mailSubject, mailBody, isBodyHTML, toMail));
 }