Exemple #1
0
        public ActionResult ChangeMyPassword(ChangeMyPasswordViewModel model, string returnUrl)
        {
            ViewBag.ReturnUrl = returnUrl;
            ViewBag.PageTitle = "USER MANAGEMENT";

            Dictionary <string, string> PanelTitles = new Dictionary <string, string>();

            PanelTitles["PanelTitle1"] = "CHANGE MY PASSWORD";
            ViewBag.PanelTitles        = PanelTitles;

            if (!ModelState.IsValid)
            {
                ViewBag.ErrorMessage = "Please check the inputs";
                return(View(model));
            }

            IdentityManager im = new IdentityManager();

            string userId = User.Identity.GetUserId();

            //string userId = "398574f6-c390-4f76-b6a8-84109e330f46";

            if (im.ChangePassword(userId, model.OldPassword, model.NewPassword))
            {
                im.DisablePasswordChangeFlag(userId);
                ViewBag.SuccessMessage = "Password Successfully Changed";
            }
            else
            {
                ViewBag.ErrorMessage = "Can't Change the Password";
            }

            return(View());
        }
        public static Courier <AppUser> PackageChangePassword(AccountChangePasswordVM package)
        {
            IdentityManager mgr = new IdentityManager();

            UpdatePasswordParcel parcel = new UpdatePasswordParcel()
            {
                User        = package.User,
                NewPassword = package.NewPassword
            };

            return(mgr.ChangePassword(parcel));
        }
Exemple #3
0
 protected void ChangePassword_Click(object sender, EventArgs e)
 {
     if (IsValid)
     {
         IPasswordManager manager = new IdentityManager(new IdentityStore(new ApplicationDbContext())).Passwords;
         IdentityResult   result  = manager.ChangePassword(User.Identity.GetUserName(), CurrentPassword.Text, NewPassword.Text);
         if (result.Success)
         {
             Response.Redirect("~/Account/Manage?m=ChangePwdSuccess");
         }
         else
         {
             AddErrors(result);
         }
     }
 }
 protected void ChangePassword_Click(object sender, EventArgs e)
 {
     if (this.IsValid)
     {
         IPasswordManager manager = new IdentityManager(new IdentityStore(new BooksLibrarySystemContext())).Passwords;
         IdentityResult   result  = manager.ChangePassword(this.User.Identity.GetUserName(), this.CurrentPassword.Text, this.NewPassword.Text);
         if (result.Success)
         {
             this.Response.Redirect("~/Account/Manage?m=ChangePwdSuccess");
         }
         else
         {
             this.AddErrors(result);
         }
     }
 }
 protected void ChangePassword_Click(object sender, EventArgs e)
 {
     if (IsValid)
     {
         IPasswordManager manager = new IdentityManager(new IdentityStore()).Passwords;
         IdentityResult result = manager.ChangePassword(User.Identity.GetUserName(), CurrentPassword.Text, NewPassword.Text);
         if (result.Success)
         {
             Response.Redirect("~/Account/Manage?m=ChangePwdSuccess");
         }
         else
         {
             AddErrors(result);
         }
     }
 }
 protected void ChangePassword_Click(object sender, EventArgs e)
 {
     if (IsValid)
     {
         IdentityManager identityManager = new IdentityManager();
         User            user            = GetUser();
         IdentityResult  result          = identityManager.ChangePassword(user.name, CurrentPassword.Text, NewPassword.Text);
         if (result.Succeeded)
         {
             IdentityHelper.SignIn(identityManager, user, isPersistent: false);
             Response.Redirect("~/Account/Manage?m=ChangePwdSuccess");
         }
         else
         {
             AddErrors(result);
         }
     }
 }