Last active
December 27, 2016 16:02
-
-
Save hoetz/3f517a2a28e4e78053b8 to your computer and use it in GitHub Desktop.
asp.net vNext Identity for dummies: your own storage providers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNet.Builder; | |
using Microsoft.Framework.DependencyInjection; | |
using Microsoft.Framework.ConfigurationModel; | |
using Microsoft.AspNet.Diagnostics; | |
using Microsoft.AspNet.Identity; | |
using ManagementWeb.Models; | |
using ManagementWeb.Storage; | |
namespace HelloMvc | |
{ | |
public class Startup | |
{ | |
public IConfiguration Configuration { get; private set; } | |
public void Configure(IApplicationBuilder app) | |
{ | |
app.UseServices(services => | |
{ | |
services.AddIdentity<ApplicationUser, IdentityRole>(Configuration) | |
.AddDefaultTokenProviders(); | |
services.AddScoped<IRoleStore<IdentityRole>, RoleStore>(); | |
services.AddScoped<IUserStore<ApplicationUser>, UserStore>(); | |
services.AddScoped<SignInManager<ApplicationUser>, SignInManager<ApplicationUser>>(); | |
services.AddScoped<ISignInManager<ApplicationUser>, ApplicationSignInManager>(); | |
services.AddMvc(); | |
}); | |
app.UseErrorPage(ErrorPageOptions.ShowAll); | |
app.UseMvc(); | |
app.UseIdentity(); | |
} | |
} | |
} | |
public class ApplicationUser : IdentityUser { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment