mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
Added fallback for injection
This commit is contained in:
parent
f835af23c3
commit
e81342ff7f
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { APP_INITIALIZER, inject, ModuleWithProviders, NgModule } from '@angular/core';
|
import { APP_INITIALIZER, inject, ModuleWithProviders, NgModule, InjectionToken } from '@angular/core';
|
||||||
import { AUTH_CONFIG, OAuthModule, OAuthStorage } from 'angular-oauth2-oidc';
|
import { AUTH_CONFIG, OAuthModule, OAuthStorage } from 'angular-oauth2-oidc';
|
||||||
import { AuthenticationService } from '../services/authentication.service';
|
import { AuthenticationService } from '../services/authentication.service';
|
||||||
import { AuthModuleConfig, AUTH_MODULE_CONFIG } from './auth-config';
|
import { AuthModuleConfig, AUTH_MODULE_CONFIG } from './auth-config';
|
||||||
@ -24,9 +24,10 @@ import { AuthRoutingModule } from './auth-routing.module';
|
|||||||
import { AuthService } from './auth.service';
|
import { AuthService } from './auth.service';
|
||||||
import { RedirectAuthService } from './redirect-auth.service';
|
import { RedirectAuthService } from './redirect-auth.service';
|
||||||
import { AuthenticationConfirmationComponent } from './view/authentication-confirmation/authentication-confirmation.component';
|
import { AuthenticationConfirmationComponent } from './view/authentication-confirmation/authentication-confirmation.component';
|
||||||
import { JWT_STORAGE_SERVICE } from '../services/jwt-helper.service';
|
|
||||||
import { StorageService } from '../../common/services/storage.service';
|
import { StorageService } from '../../common/services/storage.service';
|
||||||
|
|
||||||
|
export const JWT_STORAGE_SERVICE = new InjectionToken<OAuthStorage>('JWT_STORAGE_SERVICE');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a Login Factory function
|
* Create a Login Factory function
|
||||||
*
|
*
|
||||||
|
@ -15,11 +15,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { inject, Injectable, InjectionToken } from '@angular/core';
|
import { Inject, Injectable } from '@angular/core';
|
||||||
import { OAuthStorage } from 'angular-oauth2-oidc';
|
import { OAuthStorage } from 'angular-oauth2-oidc';
|
||||||
import { StorageService } from '../../common/services/storage.service';
|
import { StorageService } from '../../common/services/storage.service';
|
||||||
|
import { JWT_STORAGE_SERVICE } from '../oidc/auth.module';
|
||||||
export const JWT_STORAGE_SERVICE = new InjectionToken<OAuthStorage>('JWT_STORAGE_SERVICE');
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@ -36,7 +35,11 @@ export class JwtHelperService {
|
|||||||
static USER_PREFERRED_USERNAME = 'preferred_username';
|
static USER_PREFERRED_USERNAME = 'preferred_username';
|
||||||
static HXP_AUTHORIZATION = 'hxp_authorization';
|
static HXP_AUTHORIZATION = 'hxp_authorization';
|
||||||
|
|
||||||
private storageService: OAuthStorage = inject(JWT_STORAGE_SERVICE) ?? inject(StorageService);
|
private storageService: OAuthStorage;
|
||||||
|
|
||||||
|
constructor (@Inject(JWT_STORAGE_SERVICE) jwtStorageService: OAuthStorage, private defaultStorageService: StorageService) {
|
||||||
|
this.storageService = jwtStorageService ?? defaultStorageService;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decodes a JSON web token into a JS object.
|
* Decodes a JSON web token into a JS object.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user