tmp use forRoot argument to provide custom oauthstorage service

This commit is contained in:
Wojciech Duda
2024-10-11 18:28:53 +02:00
parent 07a716f74c
commit f9395dc489

View File

@@ -45,7 +45,6 @@ export function loginFactory(redirectService: RedirectAuthService): () => Promis
declarations: [AuthenticationConfirmationComponent], declarations: [AuthenticationConfirmationComponent],
imports: [AuthRoutingModule, OAuthModule.forRoot()], imports: [AuthRoutingModule, OAuthModule.forRoot()],
providers: [ providers: [
{ provide: OAuthStorage, useExisting: JWT_STORAGE_SERVICE },
{ provide: AuthenticationService}, { provide: AuthenticationService},
{ {
provide: AUTH_CONFIG, provide: AUTH_CONFIG,
@@ -63,11 +62,14 @@ export function loginFactory(redirectService: RedirectAuthService): () => Promis
] ]
}) })
export class AuthModule { export class AuthModule {
static forRoot(config: AuthModuleConfig = { useHash: false }): ModuleWithProviders<AuthModule> { static forRoot(config: AuthModuleConfig = { useHash: false }, jwtStorage?: typeof OAuthStorage): ModuleWithProviders<AuthModule> {
config.preventClearHashAfterLogin = config.preventClearHashAfterLogin ?? true; config.preventClearHashAfterLogin = config.preventClearHashAfterLogin ?? true;
return { return {
ngModule: AuthModule, ngModule: AuthModule,
providers: [{ provide: AUTH_MODULE_CONFIG, useValue: config }] providers: [
{ provide: AUTH_MODULE_CONFIG, useValue: config },
{ provide: OAuthStorage, useExisting: jwtStorage ?? StorageService }
]
}; };
} }
} }