Exemplo n.º 1
0
        public ActionResult UpdateUserInfo(string currentPassword, string newPassword,
                                           string confirmPassword, string email, string firstName, string lastName)
        {
            ViewData["PasswordLength"] = MembershipService.MinPasswordLength;

            if (!ValidateUserInfo(currentPassword, newPassword, confirmPassword, email))
            {
                return(View());
            }

            try
            {
                var changePasswordResult =
                    MembershipService.ChangePassword(User.Identity.Name, currentPassword, newPassword);
                MembershipService.UpdateUserEMial(User.Identity.Name, email);
                if (MembershipService.GetType().IsAssignableFrom(typeof(AccountMembershipService)))
                {
                    var data = new TableStorageMembershipProvider.AdditionalUserData(firstName, lastName);
                    ((AccountMembershipService)MembershipService).SetUserAdditionalData(User.Identity.Name, data);
                }
                if (changePasswordResult)
                {
                    return(RedirectToAction("About", "Home"));
                }
                ModelState.AddModelError("_FORM", "The current password is incorrect or the new password is invalid.");
                return(View());
            }
            catch
            {
                ModelState.AddModelError("_FORM", "The current password is incorrect or the new password is invalid.");
                return(View());
            }
        }
Exemplo n.º 2
0
 public void SetUserAdditionalData(string userName,
                                   TableStorageMembershipProvider.AdditionalUserData data)
 {
     if (_provider.GetType().IsAssignableFrom(typeof(TableStorageMembershipProvider)))
     {
         ((TableStorageMembershipProvider)_provider).SetUserAdditionalData(userName, data);
     }
 }
Exemplo n.º 3
0
        public ActionResult UpdateUserInfo(string currentPassword, string newPassword, 
            string confirmPassword, string email, string firstName, string lastName)
        {
            ViewData["PasswordLength"] = MembershipService.MinPasswordLength;

            if (!ValidateUserInfo(currentPassword, newPassword, confirmPassword, email))
            {
                return View();
            }

            try
            {
                var changePasswordResult =
                    MembershipService.ChangePassword(User.Identity.Name, currentPassword, newPassword);
                MembershipService.UpdateUserEMial(User.Identity.Name, email);
                if (MembershipService.GetType().IsAssignableFrom(typeof(AccountMembershipService)))
                {
                    var data = new TableStorageMembershipProvider.AdditionalUserData(firstName, lastName);
                    ((AccountMembershipService)MembershipService).SetUserAdditionalData(User.Identity.Name, data);
                }
                if (changePasswordResult)
                {
                    return RedirectToAction("About", "Home");
                }
                ModelState.AddModelError("_FORM", "The current password is incorrect or the new password is invalid.");
                return View();
            }
            catch
            {
                ModelState.AddModelError("_FORM", "The current password is incorrect or the new password is invalid.");
                return View();
            }
        }