Exemple #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <ApplicationDbContext>(options =>
                                                         options.UseSqlite(Configuration.GetConnectionString("ConnectionName")));

            services.AddDefaultIdentity <IdentityUser>()
            .AddRoles <IdentityRole>()
            .AddEntityFrameworkStores <ApplicationDbContext>();

            services.Configure <IdentityOptions>(options =>
            {
                //Password settings
                options.Password.RequireDigit           = false;
                options.Password.RequiredLength         = 6;
                options.Password.RequireNonAlphanumeric = false;
                options.Password.RequireUppercase       = false;
                options.Password.RequireLowercase       = false;

                //Lockout settings
                options.Lockout.DefaultLockoutTimeSpan  = TimeSpan.FromMinutes(1);
                options.Lockout.MaxFailedAccessAttempts = 10;
                options.Lockout.AllowedForNewUsers      = true;

                //User settings
                options.User.RequireUniqueEmail = true;
            });

            services.AddAuthorization(config =>
            {
                config.AddPolicy(Policies.CanMoveQueue, Policies.CanMoveQueuePolicy());
                config.AddPolicy(Policies.CanUpdateQueue, Policies.CanUpdateQueuePolicy());
                config.AddPolicy(Policies.IsDoctor, Policies.IsDoctorPolicy());
            });

            services.AddRazorPages();
            services.AddServerSideBlazor();
            services.AddScoped <AuthenticationStateProvider, RevalidatingIdentityAuthenticationStateProvider <IdentityUser> >();

            services.AddScoped(typeof(AppState));
            services.AddSingleton <ClinicWaitingLists>();
        }