|
|
@@ -41,7 +41,6 @@ export default class AuthService {
|
|
41
|
41
|
}
|
|
42
|
42
|
|
|
43
|
43
|
setSession (authResult) {
|
|
44
|
|
- // Set the time that the access token will expire at
|
|
45
|
44
|
let expiresAt = JSON.stringify(
|
|
46
|
45
|
authResult.expiresIn * 1000 + new Date().getTime()
|
|
47
|
46
|
)
|
|
|
@@ -52,19 +51,15 @@ export default class AuthService {
|
|
52
|
51
|
}
|
|
53
|
52
|
|
|
54
|
53
|
logout () {
|
|
55
|
|
- // Clear access token and ID token from local storage
|
|
56
|
54
|
localStorage.removeItem('access_token')
|
|
57
|
55
|
localStorage.removeItem('id_token')
|
|
58
|
56
|
localStorage.removeItem('expires_at')
|
|
59
|
57
|
this.userProfile = null
|
|
60
|
58
|
this.authNotifier.emit('authChange', false)
|
|
61
|
|
- // navigate to the home route
|
|
62
|
59
|
router.replace('home')
|
|
63
|
60
|
}
|
|
64
|
61
|
|
|
65
|
62
|
isAuthenticated () {
|
|
66
|
|
- // Check whether the current time is past the
|
|
67
|
|
- // access token's expiry time
|
|
68
|
63
|
let expiresAt = JSON.parse(localStorage.getItem('expires_at'))
|
|
69
|
64
|
return new Date().getTime() < expiresAt
|
|
70
|
65
|
}
|