コード例 #1
0
        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            if (ModelState.IsValid)
            {
                //we need the username for this to work so get the user.
                User user = UserRepository.GetUser(_db, FormsAuthService.GetCurrentUserId());
                if (MembershipService.ChangePassword(user.Username, model.OldPassword, model.NewPassword))
                {
                    return(RedirectToAction("ChangePasswordSuccess"));
                }
                else
                {
                    ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
                    this.FlashValidationSummaryErrors();
                }
            }
            else
            {
                this.FlashValidationSummaryErrors();
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
コード例 #2
0
 //Logout
 public ActionResult Logout()
 {
     _log.LogIt(FormsAuthService.GetCurrentUserId(), "Logged out");
     FormsAuthService.SignOut();
     return(RedirectToAction("Index", "Home"));
 }