-
Notifications
You must be signed in to change notification settings - Fork 18
JWT Options
Murhaf Sousli edited this page Sep 30, 2018
·
2 revisions
NOTE: The built-in JWT system used in this library is a modified clone of auth0/angular2-jwt library
The default token storage is localStorage
, but this can be changed by setting your own token's getter, setter and remover functions.
Each function must return either an Observable<string | null>
or a Promise<string | null>
import { WordPressModule } from '@ngx-wordpress/core';
import { of } from 'rxjs';
export function tokenGetter() {
return of(localStorage.getItem('token'));
}
@NgModule({
imports: [
WordPressModule.forRoot({
baseUrl: 'https://my-wordpress-site.com',
jwtOptions: {
tokenGetter: tokenGetter
}
})
],
})
export class AppModule {
}
Name | Default | Description |
---|---|---|
headerName | 'Authorization' |
The default header name |
authScheme | 'Bearer' |
The default authorization scheme |
skipWhenExpired | false |
Allow the token to be sent if it is expired |
tokenGetter | Function |
A function which returns the user's token |
tokenSetter | Function |
A function which sets the user's token |
tokenRemover | Function |
A function which removes the user's token |