-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(auth): configure auth with provider
BREAKING CHANGE: AuthModule is deprecated and use the provideAuthentification for the configuration
- Loading branch information
Showing
7 changed files
with
142 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { HTTP_INTERCEPTORS } from '@angular/common/http'; | ||
import { ModuleWithProviders, NgModule } from '@angular/core'; | ||
|
||
import { AuthFormComponent, AuthStorageService } from '@igo2/auth/form'; | ||
import { withMicrosoftSupport } from '@igo2/auth/microsoft'; | ||
import { IgoLanguageModule } from '@igo2/core/language'; | ||
import { StorageService } from '@igo2/core/storage'; | ||
|
||
import { AuthInterceptor } from '../public_api'; | ||
|
||
/** | ||
* @deprecated import the AuthFormComponent directly and configure the auth with provideAuthentification | ||
*/ | ||
@NgModule({ | ||
imports: [CommonModule, IgoLanguageModule, AuthFormComponent], | ||
exports: [AuthFormComponent] | ||
}) | ||
export class IgoAuthFormModule { | ||
static forRoot(): ModuleWithProviders<IgoAuthFormModule> { | ||
return { | ||
ngModule: IgoAuthFormModule, | ||
providers: [ | ||
{ | ||
provide: HTTP_INTERCEPTORS, | ||
useClass: AuthInterceptor, | ||
multi: true | ||
}, | ||
{ | ||
provide: StorageService, | ||
useClass: AuthStorageService | ||
}, | ||
...withMicrosoftSupport('add').providers, | ||
...withMicrosoftSupport('b2c').providers | ||
] | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { HTTP_INTERCEPTORS } from '@angular/common/http'; | ||
import { | ||
EnvironmentProviders, | ||
Provider, | ||
makeEnvironmentProviders | ||
} from '@angular/core'; | ||
|
||
import { AuthStorageService } from '@igo2/auth/form'; | ||
import { StorageService } from '@igo2/core/storage'; | ||
|
||
import { AuthFeature, AuthFeatureKind, AuthInterceptor } from './shared'; | ||
|
||
export function provideAuthentification( | ||
...features: AuthFeature<AuthFeatureKind>[] | ||
): EnvironmentProviders { | ||
const providers: Provider[] = [ | ||
{ | ||
provide: HTTP_INTERCEPTORS, | ||
useClass: AuthInterceptor, | ||
multi: true | ||
}, | ||
{ | ||
provide: StorageService, | ||
useClass: AuthStorageService | ||
} | ||
]; | ||
|
||
for (const feature of features) { | ||
providers.push(...feature.providers); | ||
} | ||
|
||
return makeEnvironmentProviders(providers); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters