Example #1
0
        public virtual ActionResult Index(ProfileEditModel p)
        {
            // manually check for password validation
            p.Elements = Application.Profile ?? new ProfileElements();
            if (p.Elements.Password &&
                (!String.IsNullOrEmpty(p.Password) ||
                 !String.IsNullOrEmpty(p.PasswordConfirmation)))
            {
                if (String.IsNullOrEmpty(p.Password))
                {
                    ModelState.AddModelError("Password", "Fill both password fields to change your password.");
                }
                if (String.IsNullOrEmpty(p.PasswordConfirmation))
                {
                    ModelState.AddModelError("PasswordConfirmation", "Fill both password fields to change your password.");
                }
                if (p.Password != p.PasswordConfirmation)
                {
                    ModelState.AddModelError("Password", "Both password entries must match to change your password.");
                }
            }

            // password is required on initial forced-update
            if (IsForcedUpdate &&
                p.Elements.Password &&
                String.IsNullOrEmpty(p.Password) &&
                String.IsNullOrEmpty(p.PasswordConfirmation))
            {
                ModelState.AddModelError("Password", "You must set your password before you can access the site.");
            }

            // validate email uniqueness
            if (p.Elements.Email)
            {
                Ascend.Core.User.ValidateEmail(CurrentUser, p.Email, UserRepository, ModelState);
            }

            if (!ModelState.IsValid)
            {
                ViewData["force"] = IsForcedUpdate;
                return(View(p));
            }

            p.Apply(p.Elements, CurrentUser);
            UserRepository.Save(CurrentUser);
            return(RedirectToAction(MVC.Site.Home.Index()));
        }
        public virtual ActionResult Index(ProfileEditModel p)
        {
            // manually check for password validation
            p.Elements = Application.Profile ?? new ProfileElements();
            if (p.Elements.Password &&
                (!String.IsNullOrEmpty(p.Password) ||
                 !String.IsNullOrEmpty(p.PasswordConfirmation)))
            {
                if (String.IsNullOrEmpty(p.Password))
                {
                    ModelState.AddModelError("Password", "Fill both password fields to change your password.");
                }
                if (String.IsNullOrEmpty(p.PasswordConfirmation))
                {
                    ModelState.AddModelError("PasswordConfirmation", "Fill both password fields to change your password.");
                }
                if (p.Password != p.PasswordConfirmation)
                {
                    ModelState.AddModelError("Password", "Both password entries must match to change your password.");
                }
            }

            // password is required on initial forced-update
            if (IsForcedUpdate &&
                p.Elements.Password &&
                String.IsNullOrEmpty(p.Password) &&
                String.IsNullOrEmpty(p.PasswordConfirmation))
            {
                ModelState.AddModelError("Password", "You must set your password before you can access the site.");
            }

            // validate email uniqueness
            if (p.Elements.Email)
            {
                Ascend.Core.User.ValidateEmail(CurrentUser, p.Email, UserRepository, ModelState);
            }

            if (!ModelState.IsValid)
            {
                ViewData["force"] = IsForcedUpdate;
                return View(p);
            }

            p.Apply(p.Elements, CurrentUser);
            UserRepository.Save(CurrentUser);
            return RedirectToAction(MVC.Site.Home.Index());
        }
Example #3
0
 public virtual ActionResult Index()
 {
     ViewData["force"] = IsForcedUpdate;
     return(View(ProfileEditModel.FromDomain(Application.Profile, Application.CustomFields ?? new string[0], CurrentUser)));
 }