本文整理汇总了C#中UserStore.HashPassword方法的典型用法代码示例。如果您正苦于以下问题:C# UserStore.HashPassword方法的具体用法?C# UserStore.HashPassword怎么用?C# UserStore.HashPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserStore
的用法示例。
在下文中一共展示了UserStore.HashPassword方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResetUserPassword
public static async Task<dynamic> ResetUserPassword(string adminId, string id)
{
CallContext cctx = Cntx;
try
{
UserServiceProxy usvc = new UserServiceProxy();
var u = await usvc.LoadEntityByKeyAsync(cctx, id);
if (u == null)
return "";
var admin = await usvc.LoadEntityByKeyAsync(cctx, adminId);
var maxadmp = await GetMaxPriority(adminId);
var maxup = await GetMaxPriority(id);
if (maxadmp.Major < maxup.Major || maxadmp.Major == maxup.Major && maxadmp.Minor < maxup.Minor)
return new { ok = false, msg = string.Format(ResourceUtils.GetString("0452f93e5e52c7eae26c4fac7aa2d5d7", "Denined! Your role level: {0} is less than the requested one."), maxadmp.Major.ToString() + "/" + maxadmp.Minor), newpwd = "" };
UserStore<ApplicationUser> store = new UserStore<ApplicationUser>();
PasswordGenerator pgen = new PasswordGenerator();
var pwd = pgen.Generate();
while (!pgen.Validate(pwd))
pwd = pgen.Generate();
u.Password = store.HashPassword(pwd);
if (u.IsPasswordModified)
{
u.LastPasswordChangedDate = DateTime.UtcNow;
await usvc.AddOrUpdateEntitiesAsync(cctx, new UserSet(), new User[] { u });
}
return new { ok = true, msg = "", newpwd = pwd };
}
catch (Exception e)
{
return new { ok = false, msg = string.Format(ResourceUtils.GetString("49dfe380301a10e682f1b3bc09136542", "Exception: {0}"), e.Message) };
}
}