本文整理汇总了C#中IMembershipService.SetUserPassword方法的典型用法代码示例。如果您正苦于以下问题:C# IMembershipService.SetUserPassword方法的具体用法?C# IMembershipService.SetUserPassword怎么用?C# IMembershipService.SetUserPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMembershipService
的用法示例。
在下文中一共展示了IMembershipService.SetUserPassword方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AccountModule
//.........这里部分代码省略.........
}
var identity = user.Identities.FirstOrDefault(i => i.ProviderName == provider);
if (identity != null)
{
repository.Remove(identity);
Request.AddAlertMessage("success", String.Format("Successfully unlinked {0} account.", provider));
return Response.AsRedirect("~/account/#identityProviders");
}
return HttpStatusCode.BadRequest;
};
Post["/newpassword"] = _ =>
{
if (!IsAuthenticated)
{
return HttpStatusCode.Forbidden;
}
string password = Request.Form.password;
string confirmPassword = Request.Form.confirmPassword;
ValidatePassword(password, confirmPassword);
ChatUser user = repository.GetUserById(Principal.GetUserId());
try
{
if (ModelValidationResult.IsValid)
{
membershipService.SetUserPassword(user, password);
repository.CommitChanges();
}
}
catch (Exception ex)
{
this.AddValidationError("_FORM", ex.Message);
}
if (ModelValidationResult.IsValid)
{
Request.AddAlertMessage("success", "Successfully added a password.");
return Response.AsRedirect("~/account/#changePassword");
}
return GetProfileView(authService, user);
};
Post["/changepassword"] = _ =>
{
if (!applicationSettings.AllowUserRegistration)
{
return HttpStatusCode.NotFound;
}
if (!IsAuthenticated)
{
return HttpStatusCode.Forbidden;
}
string oldPassword = Request.Form.oldPassword;
string password = Request.Form.password;
string confirmPassword = Request.Form.confirmPassword;
示例2: AccountModule
//.........这里部分代码省略.........
}
var identity = user.Identities.FirstOrDefault(i => i.ProviderName == provider);
if (identity != null)
{
repository.Remove(identity);
this.AddAlertMessage("success", String.Format("Successfully unlinked {0} account.", provider));
return Response.AsRedirect("~/account/#identityProviders");
}
return HttpStatusCode.BadRequest;
};
Post["/newpassword"] = _ =>
{
if (Context.CurrentUser == null)
{
return HttpStatusCode.Forbidden;
}
string password = Request.Form.password;
string confirmPassword = Request.Form.confirmPassword;
ValidatePassword(password, confirmPassword);
ChatUser user = repository.GetUserById(Context.CurrentUser.UserName);
try
{
if (ModelValidationResult.IsValid)
{
membershipService.SetUserPassword(user, password);
repository.CommitChanges();
}
}
catch (Exception ex)
{
this.AddValidationError("_FORM", ex.Message);
}
if (ModelValidationResult.IsValid)
{
this.AddAlertMessage("success", "Successfully added a password.");
return Response.AsRedirect("~/account/#changePassword");
}
return GetProfileView(authService, user);
};
Post["/changepassword"] = _ =>
{
if (Context.CurrentUser == null)
{
return HttpStatusCode.Forbidden;
}
string oldPassword = Request.Form.oldPassword;
string password = Request.Form.password;
string confirmPassword = Request.Form.confirmPassword;
if (String.IsNullOrEmpty(oldPassword))
{
this.AddValidationError("oldPassword", "Old password is required");
}
示例3: AccountModule
//.........这里部分代码省略.........
{
repository.Remove(identity);
Request.AddAlertMessage("success", String.Format(LanguageResources.Account_UnlinkCompleted, provider));
return Response.AsRedirect("~/account/#identityProviders");
}
return HttpStatusCode.BadRequest;
};
Post["/newpassword"] = _ =>
{
if (!HasValidCsrfTokenOrSecHeader)
{
return HttpStatusCode.Forbidden;
}
if (!IsAuthenticated)
{
return HttpStatusCode.Forbidden;
}
string password = Request.Form.password;
string confirmPassword = Request.Form.confirmPassword;
ValidatePassword(password, confirmPassword);
ChatUser user = repository.GetUserById(Principal.GetUserId());
try
{
if (ModelValidationResult.IsValid)
{
membershipService.SetUserPassword(user, password);
repository.CommitChanges();
}
}
catch (Exception ex)
{
this.AddValidationError("_FORM", ex.Message);
}
if (ModelValidationResult.IsValid)
{
Request.AddAlertMessage("success", LanguageResources.Authentication_PassAddSuccess);
return Response.AsRedirect("~/account/#changePassword");
}
return GetProfileView(authService, user);
};
Post["/changepassword"] = _ =>
{
if (!HasValidCsrfTokenOrSecHeader)
{
return HttpStatusCode.Forbidden;
}
if (!applicationSettings.AllowUserRegistration)
{
return HttpStatusCode.NotFound;
}
if (!IsAuthenticated)
{
return HttpStatusCode.Forbidden;