Exemplo n.º 1
0
        public ActionResult Login(string username, string password, bool persist)
        {
            var session = users.Login(username, password, this.Request);

            if (session != null)
            {
                HttpCookie authCookie = UserControllerHelper.GetAuthCookie(session, persist);
                this.Response.SetCookie(authCookie);
                var url = FormsAuthentication.GetRedirectUrl(session.SessionID, persist);
                this.Flash("Welcome back, " + session.User.DisplayName, Level.Info);
                return(Redirect(url));
            }
            else
            {
                this.Flash("Your user name and/or password were not correct.", Level.Error);
                return(View());
            }
        }
 public ActionResult ResetPassword(string newPassword, string confirmPassword)
 {
     if (newPassword != confirmPassword)
     {
         this.Flash("Passwords do not match.", Level.Error);
         return(View());
     }
     else
     {
         userManager.SetPassword(this.token.User, newPassword);
         var session = userManager.CreateSessionFor
                           (this.token.User, this.Request.UserAgent, this.Request.UserHostAddress);
         HttpCookie authCookie = UserControllerHelper.GetAuthCookie(session, false);
         this.Flash("Welcome back, " + session.User.DisplayName +
                    ". Your password has been changed and you have been logged in.",
                    Level.Info);
         this.Response.SetCookie(authCookie);
         userManager.DeleteToken(token);
         return(Redirect("/"));
     }
 }