-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEZmsUiServiceCollectionExtensions.cs
More file actions
54 lines (46 loc) · 1.96 KB
/
EZmsUiServiceCollectionExtensions.cs
File metadata and controls
54 lines (46 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Collections.Generic;
using System.Text;
using EZms.Core;
using EZms.UI.Infrastructure.Reflection;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.UI;
using Microsoft.Extensions.DependencyInjection;
namespace EZms.UI
{
public static class EZmsUIServiceCollectionExtensions
{
public static IServiceCollection AddEZmsUI(this IServiceCollection services)
{
services.ConfigureOptions(typeof(EZmsUIConfigureOptions));
services.Configure<IdentityOptions>(options =>
{
// Default Lockout settings.
options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(5);
options.Lockout.MaxFailedAccessAttempts = 5;
options.Lockout.AllowedForNewUsers = true;
// Default User settings.
options.User.RequireUniqueEmail = false;
});
services.ConfigureApplicationCookie(options =>
{
options.AccessDeniedPath = "/EZmsIdentity/Account/AccessDenied";
options.Cookie.HttpOnly = true;
options.ExpireTimeSpan = TimeSpan.FromMinutes(60);
options.LoginPath = "/EZmsIdentity/Account/Login";
options.ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter;
options.SlidingExpiration = true;
});
services.AddIdentity<IdentityUser, IdentityRole>()
.AddUserManager<UserManager<IdentityUser>>()
.AddRoleManager<RoleManager<IdentityRole>>()
.AddDefaultUI(UIFramework.Bootstrap4)
.AddEntityFrameworkStores<EZmsContext>()
.AddDefaultTokenProviders();
services.AddScoped<UserManager<IdentityUser>>();
services.AddSingleton<EditorReflectionService>();
return services;
}
}
}