当前位置: 首页>>代码示例>>C#>>正文


C# UserManager.ChangePassword方法代码示例

本文整理汇总了C#中UserManager.ChangePassword方法的典型用法代码示例。如果您正苦于以下问题:C# UserManager.ChangePassword方法的具体用法?C# UserManager.ChangePassword怎么用?C# UserManager.ChangePassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserManager的用法示例。


在下文中一共展示了UserManager.ChangePassword方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: changePassword

        public IdentityResult changePassword(passwordModel pm)
        {
            Employee emp = db.Employees.Find(pm.EmpId);

            var userStore = new UserStore<IdentityUser>();
            var UserManager = new UserManager<IdentityUser>(userStore);

            var user = UserManager.FindByName(emp.Email);

            return UserManager.ChangePassword(user.Id, pm.oldPassword, pm.newPassword);
        }
开发者ID:GenieHR,项目名称:geniehr-adminpanel,代码行数:11,代码来源:ProfileController.cs

示例2: ChangePassword_Click

 protected void ChangePassword_Click(object sender, EventArgs e)
 {
     if (IsValid)
     {
         UserManager manager = new UserManager();
         IdentityResult result = manager.ChangePassword(User.Identity.GetUserId(), CurrentPassword.Text, NewPassword.Text);
         if (result.Succeeded)
         {
             Response.Redirect("~/Account/Manage?m=ChangePwdSuccess");
         }
         else
         {
             AddErrors(result);
         }
     }
 }
开发者ID:menasbeshay,项目名称:ivalley-svn,代码行数:16,代码来源:Manage.aspx.cs

示例3: Btn_Submit_Click

        protected void Btn_Submit_Click(object sender, EventArgs e)
        {
            if(TxtNewPassword.Text.Equals(TxtConfirmPassword.Text,StringComparison.CurrentCulture))
            {
                StatusMessage.Text = "<span class='errorText'>Password & Confirm Password do not match!</span>";
            }

            var userStore = new UserStore<IdentityUser>();
            var manager = new UserManager<IdentityUser>(userStore);

            var result = manager.ChangePassword(this.Page.User.Identity.GetUserId(), TXtCurrentPassword.Text, TxtNewPassword.Text);
            if(result.Succeeded)
            {
                StatusMessage.Text = "<span class='errorText'>we have changed your password successfully!</span>";
            }
            else
            {
                StatusMessage.Text = "<span class='errorText'>Please try after some time, we are having issues!</span>";
            }

        }
开发者ID:roshchha,项目名称:FleetManagement,代码行数:21,代码来源:ChangePassword.aspx.cs

示例4: grvUsers_RowUpdating

        protected void grvUsers_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            var row = grvUsers.Rows[e.RowIndex];
            var id = grvUsers.DataKeys[e.RowIndex].Value.ToString();

            var firstName = ((TextBox)row.FindControl("txtFirstName")).Text;
            var lastName = ((TextBox)row.FindControl("txtLastName")).Text;
            var email = ((TextBox)row.FindControl("txtEmail")).Text;
            var currentPassword = ((TextBox)row.FindControl("txtCurrentPassword")).Text;
            var newPassword = ((TextBox)row.FindControl("txtNewPassword")).Text;
            var role = ((DropDownList)row.FindControl("ddlRoleEdit")).Text;
            var jobClinic = ((DropDownList)row.FindControl("ddlJobClinicEdit")).Text; //TODO: Automatically edit RelationType (exept Writer) on files.
            var isActive = ((CheckBox)row.FindControl("chkIsActive")).Checked;

            var userStore = new UserStore<IdentityUser>();
            var userManager = new UserManager<IdentityUser>(userStore);
            var user = userManager.FindById(id);

            if (user != null && (
                userManager.FindById(SharedClass.CurrentUser).UserName == "Admin" ||
                user.UserName != "Admin"
                ))
            {
                if (newPassword != "")
                {
                    var result = userManager.ChangePassword(id, currentPassword, newPassword);
                }
                userManager.SetEmail(id, email);
                userManager.RemoveFromRoles(id, userManager.GetRoles(id).ToArray());
                userManager.AddToRole(id, role);

                using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
                {
                    BSI__Clinic_Employee employee = mc.BSI__Clinic_Employees.Where(o => o.Id == id).First();
                    employee.First_Name = firstName;
                    employee.Last_Name = lastName;
                    employee.Job_Clinic = jobClinic;
                    employee.Is_Active = isActive;

                    mc.SaveChanges();
                }
            }
            grvUsers.EditIndex = -1;
        }
开发者ID:manili,项目名称:Medical_Clinic,代码行数:44,代码来源:User_Management.aspx.cs


注:本文中的UserManager.ChangePassword方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。