Example #1
0
        public ActionResult Login()
        {
            AccountLoginVM model = new AccountLoginVM();

            TryUpdateModel(model);

            AuthenticationManager.AuthenticateUser(model.Username, model.Password);

            if (AuthenticationManager.LoggedUser == null)
            {
                ModelState.AddModelError(String.Empty, "Invalid username or password.");
                return(View(model));
            }

            if (model.IsRemembered)
            {
                CookieService.CreateCookie();
            }

            if (!String.IsNullOrEmpty(model.RedirectUrl))
            {
                return(Redirect(model.RedirectUrl));
            }

            return(this.RedirectToAction <ContactsController>(c => c.List()));
        }
        public ActionResult Login()
        {
            AccountLoginVM model = new AccountLoginVM();

            TryUpdateModel(model);

            AuthenticationService.Authenticate(model.Username, model.Password);

            if (AuthenticationService.LoggedUser != null)
            {
                if (model.IsRememebered)
                {
                    CookieService.CreateCookie();
                }
                return(this.RedirectToAction <ContactsController>(c => c.List()));
            }
            else
            {
                ModelState.AddModelError("", "Invalid username or password");
                return(View(model));
            }
        }