Example #1
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            SignUpStep context = (SignUpStep)(validationContext.ObjectInstance);

            if (context.Pass == null)
            {
                return(new ValidationResult("חובה להזין סיסמא"));
            }
            if (context.Mail == null)
            {
                return(ValidationResult.Success);
            }
            if (!mailToTryCount.ContainsKey(context.Mail))
            {
                mailToTryCount.Add(context.Mail, 0);
            }

            if (++mailToTryCount[context.Mail] < 3)
            {
                return(new ValidationResult("הסיסמא אינה חזקה מספיק, אנא נסה סיסמא אחרת."));
            }
            else
            {
                Regex reg = new Regex(@"((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*]).{6,20})");
                if (!reg.IsMatch(context.Pass))
                {
                    return(new ValidationResult("הסיסמא חייבת להכיל אותיות קטנות וגדולות, מספרים, וסימן. אורך מינימלי 6 תווים"));
                }
                else
                {
                    mailToTryCount.Remove(context.Mail);
                    return(ValidationResult.Success);
                }
            }
        }
Example #2
0
        public ActionResult SignUp(SignUpStep signUpStep, string allpass, string allmail)
        {
            if (ModelState.IsValid)
            {
                // Checking if the user isn't in the system yet.
                var user = _context.FullUsers.SingleOrDefault(fu => fu.finalMailID == signUpStep.Mail);

                if (user == null)
                {
                    FullUser newUser = new FullUser();
                    newUser.finalMailID = signUpStep.Mail;
                    newUser.finalPass   = signUpStep.Pass;
                    newUser.isVerifyed  = false;
                    newUser.allMail    += allmail;
                    _context.FullUsers.Add(newUser);
                    _context.SaveChanges();


                    string host = Url.Action("validate", "Login", new { id = 5 }, Request.Scheme);
                    host  = host.Substring(0, host.Length - 2);
                    host += "?";
                    EmailValidationHelper emailValidationHelper = new EmailValidationHelper(_context);
                    emailValidationHelper.SendMailValidation(newUser, host);

                    return(RedirectToAction("ValidationMailSent", "Index"));
                }
                else
                {
                    ViewBag.Message = "המשתמש כבר קיים במערכת";
                    ViewBag.back    = 1;
                    return(View("SignUp", signUpStep));
                }
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(signUpStep.Mail))
                {
                    var user = _context.FullUsers.SingleOrDefault(su => su.finalMailID == signUpStep.Mail);   //ElasticsearchUtils.Search(signUpStep.Mail);
                    if (user != null)
                    {
                        ViewBag.back    = 1;
                        ViewBag.Message = "המשתמש כבר קיים במערכת";
                        return(View("SignUp", signUpStep));
                    }
                }
            }

            signUpStep.Pass        = "";
            signUpStep.ConfirmPass = "";

            return(View("SignUp", signUpStep));
        }
Example #3
0
 public IActionResult ResetPassword(SignUpStep signUpStep, string allpass)
 {
     if (ModelState.IsValid)
     {
         FullUser f = _context.FullUsers.SingleOrDefault(fu => fu.finalMailID == signUpStep.Mail);
         f.finalPass   = signUpStep.Pass;
         f.finalMailID = signUpStep.Mail;
         f.finalPass   = signUpStep.Pass;
         f.isVerifyed  = true;
         f.allPass    += allpass;
         _context.Update(f);
         _context.SaveChanges();
         return(RedirectToAction("PassChange", "Index"));
     }
     signUpStep.Pass        = "";
     signUpStep.ConfirmPass = "";
     return(View(signUpStep));
 }
Example #4
0
        public ActionResult ForgetPass(SignUpStep sus, string allmail)
        {
            string host = Url.Action("ResetPassword", "NewSignUp", new { id = 5 }, Request.Scheme);

            host  = host.Substring(0, host.Length - 2);
            host += "?";
            EmailValidationHelper emailValidationHelper = new EmailValidationHelper(_context);
            FullUser user = _context.FullUsers.SingleOrDefault(fu => fu.finalMailID == sus.Mail);

            // case email is not exist in DB
            if (user == null)
            {
                return(RedirectToAction("Error", "Index", new { eror = "string" }));
            }

            user.allMail += allmail;

            _context.Update(user);
            _context.SaveChanges();
            emailValidationHelper.SendMailValidation(user, host);
            return(RedirectToAction("ValidationMailSent", "Index"));
        }