无法在UserManager,AspNet.Identity 3中找到PasswordValidator属性

时间:2015-12-05 21:21:48

标签: c# asp.net-mvc asp.net-identity asp.net-identity-3

我想更改注册表单的密码要求,但我无法在UserManager类中找到PasswordValidator属性。

我正在使用AspNet.Identity.EntityFramework 3.0.0-beta5

//Input start
var num1 = prompt("Num1");
if ( ( num1 <= 0 ) || ( num1 > 0 ) ) {

  var act = prompt("Action");
  if ( (act == "+") || (act == "-") || (act == "*") || (act == "/") ||
  (act == "%") ) {

    var num2 = prompt("Num2");
    if ( ( num2 <= 0 ) || ( num2 > 0 ) ) {
//Input end

//Calculator start

function CalculationFN () {

alert(num1); alert(act); alert(num2);

  switch ( act ) {

        case "+":
           num1 = +num1 + +num2;
            ReCalFN ();
            break;

        case "-":
           num1 = +num1 - +num2;
            ReCalFN ();
            break;

        case "*":
           num1 = +num1 * +num2;
            ReCalFN ();
            break;

        case "/":
           if ( ( act == "/" ) && ( num2 == 0) )
           { alert("Error: Undifiend"); } else {
            num1 = +num1 / +num2; }
             ReCalFN ();
            break;

        case "%":
           num1 = +num1 * +num2 /100;
            ReCalFN ();
            break;

          }

       }

//.............................

       function ReCalFN () {

         var act = prompt(" " + num1 + "\n New Action");
         if ( (act == "+") || (act == "-") || (act == "*") || (act == "/") ||
         (act == "%") ) {
           
//"num2 = undifined" why?...................
alert(num1); alert(act); alert(num2);

           var num2 = prompt("AnyNum");
           if ( ( num2 <= 0 ) || ( num2 > 0 ) ) {

alert(num1); alert(act); alert(num2);

     CalculationFN ();

           } else { alert("Error: no valid action"); }

         } else { alert("Error: no valid value"); }
       }

CalculationFN ();

//Calculator end

//Error start
    } else { alert("Error: no valid value"); }
  } else { alert("Error: no valid action"); }
} else { alert("Error: no valid value"); }
//Error end

(为了进行比较,在Microsoft ASP.NET Identity 2.0中,private readonly UserManager<AppUser> _userManager; private readonly SignInManager<AppUser> _signInManager; public AccountController(UserManager<AppUser> userManager, SignInManager<AppUser> signInManager) { _userManager = userManager; _signInManager = signInManager; // UserManager does not contain a definition for PasswordValidator //_userManager.PasswordValidator } 的文档为here。)

1 个答案:

答案 0 :(得分:0)

所以我设法通过更改startup.cs中的标识选项来修复它

这就是它之前的样子

    services.AddIdentity<Models.Identity.AppUser, IdentityRole>()
       .AddEntityFrameworkStores<test.Models.Identity.IdentityDataContext>();

这就是现在的样子

services.AddIdentity<Models.Identity.AppUser, IdentityRole>(options =>
            {
                options.Password.RequireDigit = false;
                options.Password.RequiredLength = 6;
                options.Password.RequireLowercase = false;
                options.Password.RequireNonLetterOrDigit = false;
                options.Password.RequireUppercase = false;
            })
                .AddEntityFrameworkStores<test.Models.Identity.IdentityDataContext>();