身份3重置密码无法登录

时间:2015-12-12 20:04:01

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

我正在使用asp.net 5,MVC 6,使用EF7的Identity 3以及更新到RC1的所有内容

我的启动服务配置中有以下内容:

        services.AddCaching();
        services.AddSession();

     services.AddEntityFramework().AddInMemoryDatabase().AddDbContext<MyContext>(o => o.UseInMemoryDatabase());
        services.AddIdentity<User, Role>()
            .AddEntityFrameworkStores<MyContext, Guid>()
            .AddDefaultTokenProviders();


        services.AddAuthentication();

在我的启动配置中,我有:

        app.UseSession();
        app.UseIdentity();

我尝试使用ResetPasswordAsync重置用户密码,但出于某些奇怪的原因,我在这里遇到了一些问题。

  • 首先,当我尝试重置密码时,我得到的错误是我需要大写,即使我有大写,小写和数字。

  • 第二,如果我禁用了services.AddIdentity和reset password中的所有要求,我会获得成功,但是当我尝试使用新密码登录时,它不起作用。

我真的不明白最新情况,但是有没有已知的错误?

身份选项

        options.User.RequireUniqueEmail = true;
        //Password
        options.Password.RequiredLength = 7;
        options.Password.RequireUppercase = false;
        options.Password.RequireLowercase = false;

        options.SignIn.RequireConfirmedEmail = false;
        options.AccessDeniedPath = new PathString("/Account/Login");
        options.LoginPath = new PathString("/Account/Login");
        options.LogoutPath = new PathString("/");
        options.AuthenticationScheme = IdentityCookieOptions.ApplicationCookieAuthenticationType = "ApplicationCookie";
        options.AutomaticChallenge = true;

我在github上复制了这个问题:https://github.com/lasrol/EmptyDB

1 个答案:

答案 0 :(得分:0)

问题只是我的代码中的一个大错误我没有将正确的变量传递给API。这有效:

Error: Could not find or load main class login

这不起作用(出于明显的原因。提示:用户ID:P):

        var token = model.Token;
        var userid = model.UserId;
        var user = await _userManager.FindByIdAsync(userid);
        var result = await _userManager.ResetPasswordAsync(user, token, model.Password);
相关问题