Last active
August 30, 2019 13:54
-
-
Save yonzin/7bc7770f24b0475e5668d2e852d584d0 to your computer and use it in GitHub Desktop.
auth0/angular2-jwt ionic and capacitor storage configuration
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
import { JwtModule, JWT_OPTIONS } from '@auth0/angular-jwt'; | |
import { Plugins } from '@capacitor/core'; | |
// ... | |
export function jwtOptionsFactory() { | |
return { | |
tokenGetter: () => { | |
return Plugins.Storage.get({ key: 'jwt_token' }).then(storedData => storedData.value); | |
}, | |
whitelistedDomains: environment.whitelistedDomains, | |
blacklistedRoutes: environment.blacklistedRoutes, | |
}; | |
} | |
// ... | |
@NgModule({ | |
// ... | |
imports: [ | |
JwtModule.forRoot({ | |
jwtOptionsProvider: { | |
provide: JWT_OPTIONS, | |
useFactory: jwtOptionsFactory, | |
deps: [] | |
} | |
}) | |
] | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment