Skip to content

Commit

Permalink
a workaround for #43
Browse files Browse the repository at this point in the history
  • Loading branch information
mehrdadgit committed Aug 11, 2018
1 parent 631efbb commit bf8a1a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ export class App {
loginToggled = false;
landingMessage = 'Silakan login untuk mengakses peta';

constructor(api, i18n, router) {
this.api = api;
this.i18n = i18n;
this.router = router;
let self = this;

checkIfLoggedIn(){
// If the token has expired log the user out
if (tokenIsExpired()) {
this.isAuthenticated = false;
Expand All @@ -42,6 +38,19 @@ export class App {
this.username = profile.email;
}
}
}

constructor(api, i18n, router) {
this.api = api;
this.i18n = i18n;
this.router = router;
let self = this;
self.checkIfLoggedIn();
document.addEventListener('auth-changed',function(){
self.checkIfLoggedIn();
});



}

Expand Down
1 change: 1 addition & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export function handleAuthentication(router) {
localStorage.setItem('id_token', authResult.idToken);
localStorage.setItem('profile', JSON.stringify(profile));
router.navigate('map');
document.dispatchEvent(new Event('auth-changed'));
});

} else if (err) {
Expand Down

0 comments on commit bf8a1a5

Please sign in to comment.