Beispiel #1
0
        public IActionResult ForgotPassword(ForgotPasswordViewModel forgot)
        {
            if (!ModelState.IsValid)
            {
                return(View(forgot));
            }
            string fixedemail = FixedText.fixedemail(forgot.Email);
            User   user       = _userServices.getuserbyEmail(fixedemail);

            if (user == null)
            {
                ModelState.AddModelError("Email", "حسابی با این مشخصات یافت نسد");
                return(View(forgot));
            }
            string bodyemail = _viewrender.RenderToStringAsync("_ForgotPassword", user);

            SendEmail.Send(user.Email, "بازیابی کلمه عبوری", bodyemail);
            ViewBag.issuccess = true;

            return(View());
        }
Beispiel #2
0
        public IActionResult Register(RegisterviewModel register)
        {
            if (!ModelState.IsValid)
            {
                return(View(register));
            }

            if (_userServices.isExistusername(register.Username))
            {
                ModelState.AddModelError("Username", "نام کاربری معتبر نمی باشد");
                return(View(register));
            }
            if (_userServices.isExistemail(FixedText.fixedemail(register.Email)))
            {
                ModelState.AddModelError("Email", "ایمیل معتر نمی باشد");
                return(View(register));
            }

            User user = new User()
            {
                Activecode   = NameGenerator.Generateuniqcode(),
                Email        = FixedText.fixedemail(register.Email),
                isActive     = false,
                Password     = PasswordHelper.EncodePasswordMd5(register.Password),
                Username     = register.Username,
                RegisterDate = DateTime.Now,
                UserAvatar   = "Defult.jpg"
            };

            _userServices.adduser(user);
            #region sende Activation email

            string body = _viewrender.RenderToStringAsync("_ActivateEmail", user);
            SendEmail.Send(user.Email, "فعال سازی", body);


            #endregion

            return(View("SuccedRegister", user));
        }