Exemple #1
0
        public ActionResult LogOn(string ReturnUrl)
        {
            if (Security.SecurityService.LoggedInUser == null)
            {
                Security.SecurityService.TryLoginFromCookie(Request.Cookies);
                if (Security.SecurityService.LoggedInUser != null)
                    return RedirectAfterLogOn(ReturnUrl);
            }

            var vm = new LogOnViewModel();
            vm.RememberLogin = true;
            return View(vm);
        }
Exemple #2
0
        public ActionResult LogOn(LogOnViewModel lovm, string ReturnUrl)
        {
            if (this.ModelState.IsValid)
            {
                lovm.Username = lovm.Username.Trim();
                lovm.Password = lovm.Password.Trim();
                if (Security.SecurityService.Login(lovm.Username, lovm.Password))
                {
                    if (lovm.RememberLogin)
                        RememberLogin();

                    return RedirectAfterLogOn(ReturnUrl);
                }
                else
                    ModelState.AddModelError("", "Invalid username/password.");
            }

            return View(lovm);
        }