I receive the above error after I have successfully registered a user and confirmed authentication. The error occurs when I try to call
await _signInManager.SignInAsync(applicationUser, isPersistent);
I first assign the service to the IServiceCollection with this:
services.AddIdentity<ApplicationUser, IdentityRole<int>>(
config => { config.User.RequireUniqueEmail = true;
config.Cookies.ApplicationCookie.LoginPath = "/Account/Login";
config.Cookies.ApplicationCookie.Events = new CookieAuthenticationEvents()
{
OnRedirectToLogin = async ctx =>
{
if (ctx.Request.Path.StartsWithSegments("/api") && ctx.Response.StatusCode == 200)
{
ctx.Response.StatusCode = 401;
}
else
{
ctx.Response.Redirect(ctx.RedirectUri);
}
await Task.Yield();
}
};
}).AddEntityFrameworkStores<VisualJobsDbContext, int>()
.AddDefaultTokenProviders();
and in my Config method of startup I call app.UseIdentity();
before the call to app.UseMvc
if I change my call to be:
var myVal = await _signInManager.PasswordSignInAsync(applicationUser, password, true, false);
them myVal is goes to 'Failed' I do not get any error thrown