嘗試將默認的最小密碼長度更改爲4個字符。我知道,4!可笑,對!不是我的電話。在MVC 5成員中更改密碼長度
無論如何,我在RegisterViewModel
上更改了它,但實際上並沒有改變它。爲了說明我已經發布了下面的代碼。 ModleState.IsValid
根據更新的ViewModel正確返回。然而,然後調用UserManager.CreateAsync()
與一條錯誤消息返回False
「密碼必須至少6個字符」
我已經按照這個,非常類似的帖子(Change Password...)的步驟,但它並不適用於MVC 5個工作據我所知,就我而言。它仍然返回相同的消息。
//
// POST: /Account/Register
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Register(RegisterViewModel model)
{
if (ModelState.IsValid)
{
var user = new ApplicationUser() { UserName = model.UserName, LastLogin = model.LastLogin };
// This is where it 'fails' on the CreateAsync() call
var result = await UserManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{
await SignInAsync(user, isPersistent: false);
return RedirectToAction("Index", "Home");
}
else
{
AddErrors(result);
}
}
// If we got this far, something failed, redisplay form
return View(model);
}