1
- using CheckDrive . Application . Interfaces ;
2
- using CheckDrive . Domain . Interfaces ;
1
+ using CheckDrive . Domain . Interfaces ;
2
+ using CheckDrive . Application . Interfaces ;
3
3
using CheckDrive . Infrastructure . Configurations ;
4
4
using CheckDrive . Infrastructure . Email ;
5
5
using CheckDrive . Infrastructure . Persistence ;
9
9
using Microsoft . EntityFrameworkCore ;
10
10
using Microsoft . Extensions . Configuration ;
11
11
using Microsoft . Extensions . DependencyInjection ;
12
+ using CheckDrive . Infrastructure . Helpers ;
13
+ using CheckDrive . Application . Interfaces . Auth ;
12
14
13
15
namespace CheckDrive . Infrastructure . Extensions ;
14
16
@@ -18,8 +20,9 @@ public static IServiceCollection RegisterInfrastructure(this IServiceCollection
18
20
{
19
21
AddPersistence ( services , configuration ) ;
20
22
AddConfigurations ( services , configuration ) ;
21
- AddFluentEmail ( services , configuration ) ;
23
+ AddEmail ( services , configuration ) ;
22
24
AddServices ( services ) ;
25
+ AddIdentity ( services ) ;
23
26
24
27
return services ;
25
28
}
@@ -28,10 +31,6 @@ private static void AddPersistence(IServiceCollection services, IConfiguration c
28
31
{
29
32
services . AddDbContext < ICheckDriveDbContext , CheckDriveDbContext > ( options =>
30
33
options . UseSqlServer ( configuration . GetConnectionString ( "DefaultConnection" ) ) ) ;
31
-
32
- services . AddIdentity < IdentityUser , IdentityRole > ( )
33
- . AddEntityFrameworkStores < CheckDriveDbContext > ( )
34
- . AddDefaultTokenProviders ( ) ;
35
34
}
36
35
37
36
private static void AddConfigurations ( IServiceCollection services , IConfiguration configuration )
@@ -52,7 +51,7 @@ private static void AddConfigurations(IServiceCollection services, IConfiguratio
52
51
. ValidateOnStart ( ) ;
53
52
}
54
53
55
- private static void AddFluentEmail ( IServiceCollection services , IConfiguration configuration )
54
+ private static void AddEmail ( IServiceCollection services , IConfiguration configuration )
56
55
{
57
56
var emailSettings = configuration
58
57
. GetSection ( EmailConfigurations . SectionName )
@@ -82,5 +81,25 @@ private static void AddServices(IServiceCollection services)
82
81
{
83
82
services . AddScoped < IEmailService , EmailService > ( ) ;
84
83
services . AddScoped < ISmsService , SmsService > ( ) ;
84
+ services . AddSingleton < IJwtTokenGenerator , JwtTokenGenerator > ( ) ;
85
+ }
86
+
87
+ private static void AddIdentity ( IServiceCollection services )
88
+ {
89
+ services . AddIdentity < IdentityUser , IdentityRole > ( options =>
90
+ {
91
+ options . Password . RequiredLength = 7 ;
92
+ options . Password . RequireUppercase = false ;
93
+ options . Password . RequireLowercase = false ;
94
+ options . Password . RequireNonAlphanumeric = false ;
95
+ options . Password . RequireDigit = false ;
96
+ } )
97
+ . AddEntityFrameworkStores < CheckDriveDbContext > ( )
98
+ . AddDefaultTokenProviders ( ) ;
99
+
100
+ services . Configure < DataProtectionTokenProviderOptions > ( options =>
101
+ {
102
+ options . TokenLifespan = TimeSpan . FromHours ( 12 ) ;
103
+ } ) ;
85
104
}
86
105
}
0 commit comments