Example #1
0
 public virtual ActionResult SetUser(LogonModel model)
 {
     if (string.IsNullOrWhiteSpace(model.UserName))
     {
         return(RedirectToAction(MVC_DcmsMobile.Home.Index()));
     }
     return(View(this.Views.Index, model));
 }
Example #2
0
        public virtual ActionResult Index(string returnUrl)
        {
            var model = new LogonModel
            {
                ReturnUrl = returnUrl
            };

            return(View(this.Views.Index, model));
        }
Example #3
0
        public virtual ActionResult Login(LogonModel model)
        {
            Contract.Requires(model != null, "The passed model should never be null");

            // If both user name empty, redirect to home page. Supports mobile behavior
            if (string.IsNullOrWhiteSpace(model.UserName) || string.IsNullOrWhiteSpace(model.Password))
            {
                this.AddStatusMessage("Login cancelled");
                return(RedirectToAction(MVC_DcmsMobile.Home.Index()));
            }

            try
            {
                bool b = MembershipService.ValidateUser(model.UserName, model.Password);
                if (b)
                {
                    FormsService.SignIn(model.UserName, false);
                    AddStatusMessage(string.Format("Logged in as {0}", model.UserName));
                    if (string.IsNullOrEmpty(model.ReturnUrl))
                    {
                        return(RedirectToAction(MVC_DcmsMobile.Home.Index()));
                    }
                    else
                    {
                        return(Redirect(model.ReturnUrl));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Invalid username/password. Please try again.");
                    // Empty model forces restart of login
                    return(View(this.Views.Index, new LogonModel()));
                }
            }
            catch (MembershipPasswordException)
            {
                var cpmodel = new ChangeExpiredPasswordModel
                {
                    UserName  = model.UserName,
                    ReturnUrl = model.ReturnUrl,
                    //Password = model.Password
                };
                this.TempData[OLD_PASSWORD] = model.Password;
                ModelState.AddModelError("", "Your password has expired. Please change it now.");
                return(View(this.Views.ChangeExpiredPassword, cpmodel));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View(this.Views.Index, model));
            }
        }
Example #4
0
 public virtual ActionResult SetUser(LogonModel model)
 {
     if (string.IsNullOrWhiteSpace(model.UserName))
     {
         return RedirectToAction(MVC_DcmsMobile.Home.Index());
     }
     return View(this.Views.Index, model);
 }
Example #5
0
        public virtual ActionResult Login(LogonModel model)
        {
            Contract.Requires(model != null, "The passed model should never be null");

            // If both user name empty, redirect to home page. Supports mobile behavior
            if (string.IsNullOrWhiteSpace(model.UserName) || string.IsNullOrWhiteSpace(model.Password))
            {
                this.AddStatusMessage("Login cancelled");
                return RedirectToAction(MVC_DcmsMobile.Home.Index());
            }

            try
            {
                bool b = MembershipService.ValidateUser(model.UserName, model.Password);
                if (b)
                {
                    FormsService.SignIn(model.UserName, false);
                    AddStatusMessage(string.Format("Logged in as {0}", model.UserName));
                    if (string.IsNullOrEmpty(model.ReturnUrl))
                    {
                        return RedirectToAction(MVC_DcmsMobile.Home.Index());
                    }
                    else
                    {
                        return Redirect(model.ReturnUrl);
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Invalid username/password. Please try again.");
                    // Empty model forces restart of login
                    return View(this.Views.Index, new LogonModel());
                }
            }
            catch (MembershipPasswordException)
            {
                var cpmodel = new ChangeExpiredPasswordModel
                {
                    UserName = model.UserName,
                    ReturnUrl = model.ReturnUrl,
                    //Password = model.Password
                };
                this.TempData[OLD_PASSWORD] = model.Password;
                ModelState.AddModelError("", "Your password has expired. Please change it now.");
                return View(this.Views.ChangeExpiredPassword, cpmodel);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return View(this.Views.Index, model);
            }
        }
Example #6
0
 public virtual ActionResult Index(string returnUrl)
 {
     var model = new LogonModel
     {
          ReturnUrl = returnUrl
     };
     return View(this.Views.Index, model);
 }