身份3重设密码无法登录
Identity 3 reset password unable to login
我正在使用 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 中的所有要求并重设密码,我会成功,但是当我尝试使用新密码登录时,它不起作用。
我不太明白这是怎么回事,但是有什么已知的错误吗?
身份选项
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
这个问题只是我在代码中的一个大错误,我没有将正确的变量传递给 API。这有效:
var token = model.Token;
var userid = model.UserId;
var user = await _userManager.FindByIdAsync(userid);
var result = await _userManager.ResetPasswordAsync(user, token, model.Password);
这没有用(出于明显的原因。提示:userid :P):
var token = model.Token;
var userid = model.UserId;
var user = await _userManager.FindByIdAsync(userid);
var result = await _userManager.ResetPasswordAsync(user, token, userid);
我正在使用 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 中的所有要求并重设密码,我会成功,但是当我尝试使用新密码登录时,它不起作用。
我不太明白这是怎么回事,但是有什么已知的错误吗?
身份选项
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
这个问题只是我在代码中的一个大错误,我没有将正确的变量传递给 API。这有效:
var token = model.Token;
var userid = model.UserId;
var user = await _userManager.FindByIdAsync(userid);
var result = await _userManager.ResetPasswordAsync(user, token, model.Password);
这没有用(出于明显的原因。提示:userid :P):
var token = model.Token;
var userid = model.UserId;
var user = await _userManager.FindByIdAsync(userid);
var result = await _userManager.ResetPasswordAsync(user, token, userid);