本文整理汇总了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);
}
示例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);
}
}
}
示例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>";
}
}
示例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;
}