示例#1
0
        public ActionResult LogOn(AuthenticationModel credentials, string returnUrl)
        {
            try
            {
                var user    = _userAuthenticator.Authenticate(credentials.UserName, credentials.Password);
                var webUser = WebUser.Create(user);

                GenerateAndStoreCookies(webUser);
                UserSession.Current = webUser;

                return(!string.IsNullOrEmpty(returnUrl) ? (ActionResult)Redirect(returnUrl) : RedirectToAction("Index", "Dashboard"));
            }
            catch (UserAuthenticationException authFailure)
            {
                credentials.AuthenticationError = authFailure.FailureReason.ToString();

                return(View(credentials));
            }
        }