Directly initialize JwtHelperService in auth service
This commit is contained in:
@@ -1,29 +1,13 @@
|
||||
import {ApplicationConfig, importProvidersFrom, provideZoneChangeDetection} from '@angular/core';
|
||||
import {ApplicationConfig, provideZoneChangeDetection} from '@angular/core';
|
||||
import {provideRouter} from '@angular/router';
|
||||
import {JwtHelperService, JwtModule} from '@auth0/angular-jwt';
|
||||
import {CookieService} from 'ngx-cookie-service';
|
||||
|
||||
import {routes} from './app.routes';
|
||||
|
||||
export function jwtTokenGetter() {
|
||||
return localStorage.getItem('jwt');
|
||||
}
|
||||
|
||||
export const appConfig: ApplicationConfig = {
|
||||
providers: [
|
||||
provideZoneChangeDetection({eventCoalescing: true}),
|
||||
provideRouter(routes),
|
||||
CookieService,
|
||||
{
|
||||
provide: JwtHelperService,
|
||||
useValue: new JwtHelperService()
|
||||
},
|
||||
importProvidersFrom(
|
||||
JwtModule.forRoot({
|
||||
config: {
|
||||
tokenGetter: jwtTokenGetter
|
||||
}
|
||||
})
|
||||
)
|
||||
]
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user