コード例 #1
0
        public static IServiceCollection AddCSharpIdentity <TContext>(this IServiceCollection services)
            where TContext : CSharpJWTContext
        {
            services.AddIdentity <User, Role>(Options => CSharpUserManager.CreateOptions(Options))
            .AddEntityFrameworkStores <TContext>()
            .AddDefaultTokenProviders();

            services.AddScoped <CSharpUserManager, CSharpUserManager>();

            services.AddScoped <CSharpSignInManager, CSharpSignInManager>();

            services.AddScoped <IClientService, ClientService>();

            services.AddScoped <ITokenService, TokenService>();

            return(services);
        }
コード例 #2
0
        public static IServiceCollection AddCSharpJWTIdentity <TContext>(this IServiceCollection services,
                                                                         Action <DbContextOptionsBuilder> optionsAction)
            where TContext : CSharpJWTContext
        {
            services.AddDbContext <TContext>(optionsAction);

            services.AddIdentity <User, Role>(Options => CSharpUserManager.CreateOptions(Options))
            .AddEntityFrameworkStores <TContext>()
            .AddDefaultTokenProviders();

            services.AddScoped <ITokenService, TokenService>();

            return(services
                   .AddCSharpUserManager()
                   .AddCSharpSignInManager()
                   .AddClientService()
                   .AddClaimService());
        }