Skip to content

Instantly share code, notes, and snippets.

@ghstahl
Last active October 12, 2020 17:04
Show Gist options
  • Save ghstahl/2a3ba13ce8197cb638626fb632e2237d to your computer and use it in GitHub Desktop.
Save ghstahl/2a3ba13ce8197cb638626fb632e2237d to your computer and use it in GitHub Desktop.
Keeping Authentication and Session in sync in asp.net core 3.x - Startup.cs identity
services.AddIdentity<IdentityUser,IdentityRole>(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
// services.AddDefaultIdentity must be adding its own fake
// Switched to services.AddIdentity<IdentityUser,IdentityRole>, and now I have to add it.
services.AddScoped<IEmailSender, FakeEmailSender>();
services.AddScoped<IUserClaimsPrincipalFactory<IdentityUser>, SeedSessionClaimsPrincipalFactory>();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment