public ActionResult ForgotPassword(ForgotPasswordViewModel forgot)
        {
            if (ModelState.IsValid)
            {
                var user = _uow.UserRepository.GetUserByEmail(forgot.Email);
                if (user != null)
                {
                    if (user.IsActive)
                    {
                        string body = PartialToString.RenderPartialView("ManageEmail", "ForgotPasswordEmail", user);
                        SendEmail.Send(forgot.Email, "بازیابی کلمه عبور", body);
                        return(View("SuccessForgotPassword", user));
                    }
                    else
                    {
                        ModelState.AddModelError("Email", "");
                    }
                }
                else
                {
                    ModelState.AddModelError("Email", "");
                }
            }

            return(View());
        }
Beispiel #2
0
 public ActionResult ForgotPassword(ForgotPasswordViewModel forgot)
 {
     if (ModelState.IsValid)
     {
         var user = _userBusiness.GetByEmail(forgot.Email);
         if (user != null)
         {
             if (user.IsActive)
             {
                 string body = PartialToString.RenderPartialView("ManageEmail", "ForgotPassword", user);
                 SendEmail.Send(user.Email, "ایمیل تغییر کلمه عبور", body);
                 TempData["Title"]   = "تغییر کلمه عبور";
                 TempData["Message"] = "برای تغییر کلمه عبور به ایمیل خود مراجعه کنید و بر روی لینک کلیک کنید";
                 TempData["Class"]   = "alert alert-success";
                 return(View("Notification"));
             }
             else
             {
                 ViewBag.Message = "حساب کاربری شما فعال نیست";
                 ViewBag.Class   = "alert alert-danger";
                 return(View());
             }
         }
         else
         {
             ViewBag.Message = "حساب کاربری موجود نیست";
             ViewBag.Class   = "alert alert-danger";
             return(View());
         }
     }
     return(View());
 }
 public ActionResult Register(RegisterViewModel register)
 {
     if (ModelState.IsValid)
     {
         var user = userService.InsertUserService(register);
         if (user != null)
         {
             // Send Active Code To Email
             string body = PartialToString.RenderPartialView("ManageEmail", "ActivationEmail", user);
             SendEmail.Send(user.Email, "ایمیل فعالسازی", body);
             return(View("SuccessRegister", user));
         }
         else
         {
             ModelState.AddModelError("Email", "ایمیل وارد شده قبلا ثبت شده است");
         }
     }
     return(View());
 }
Beispiel #4
0
        public ActionResult Register(RegisterViewModel register)
        {
            if (ModelState.IsValid)
            {
                bool checkEmail = _userBusiness.CheckEmail(register.Email.Trim().ToLower());
                if (checkEmail == false)
                {
                    User user = new User()
                    {
                        UserId     = Guid.NewGuid().ToString(),
                        FirstName  = register.FirstName,
                        LastName   = register.LastName,
                        Email      = register.Email,
                        Password   = FormsAuthentication.HashPasswordForStoringInConfigFile(register.Password, "MD5"),
                        ActiveCode = Guid.NewGuid().ToString(),
                        IsActive   = false,
                        JoinDate   = DateTime.Now,
                        RoleId     = 1
                    };
                    _userBusiness.Insert(user);
                    _userBusiness.Save();

                    // Send Active Code To Email
                    string body = PartialToString.RenderPartialView("ManageEmail", "ActiveUser", user);
                    SendEmail.Send(user.Email, "ایمیل فعالسازی", body);
                    TempData["Title"]   = "فعالسازی حساب کاربری";
                    TempData["Message"] = "برای فعالسازی حساب کاربری به ایمیل خود مراجعه کنید و بر روی لینک کلیک کنید";
                    TempData["Class"]   = "alert alert-success";
                    return(View("Notification"));
                }
                else
                {
                    ViewBag.Message = "ایمیل وارد شده تکراری است";
                    ViewBag.Class   = "alert alert-danger";
                    return(View());
                }
            }
            return(View());
        }