Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
AURA
dashboard
Commits
6332ae47
Commit
6332ae47
authored
Apr 05, 2018
by
Andrea Ida Malkah Klaura
Browse files
FIX: set new access token after renewal + refactor
parent
aa220d26
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/App.vue
View file @
6332ae47
...
...
@@ -42,7 +42,7 @@ export default {
logged_in
:
false
},
userOIDC
:
null
,
mgr
:
new
oidc
.
UserManager
({
oidc
mgr
:
new
oidc
.
UserManager
({
userStore
:
new
oidc
.
WebStorageStateStore
(),
authority
:
process
.
env
.
API_STEERING_OIDC_URI
,
// the client id has to be a string, therefore we add the + ''
...
...
@@ -54,7 +54,8 @@ export default {
scope
:
'
openid profile email
'
,
post_logout_redirect_uri
:
process
.
env
.
API_STEERING_OIDC_REDIRECT_URI_POSTLOGOUT
,
loadUserInfo
:
true
,
automaticSilentRenew
:
true
// automaticSilentRenew: true
automaticSilentRenew
:
false
})
}
},
...
...
@@ -66,68 +67,78 @@ export default {
},
methods
:
{
signIn
()
{
this
.
mgr
.
signinRedirect
().
catch
(
function
(
err
)
{
this
.
oidc
mgr
.
signinRedirect
().
catch
(
function
(
err
)
{
console
.
log
(
err
)
})
},
signOut
()
{
let
self
=
this
this
.
mgr
.
signoutRedirect
().
then
(
function
(
resp
)
{
this
.
oidc
mgr
.
signoutRedirect
().
then
(
function
(
resp
)
{
self
.
user
.
logged_in
=
false
console
.
log
(
'
signed out
'
,
resp
)
}).
catch
(
function
(
err
)
{
console
.
log
(
err
)
})
},
getUser
()
{
get
OIDC
User
()
{
let
self
=
this
this
.
mgr
.
getUser
().
then
(
function
(
u
)
{
if
(
u
==
null
)
{
this
.
oidc
mgr
.
getUser
().
then
(
function
(
u
ser
)
{
if
(
u
ser
==
null
)
{
self
.
user
.
logged_in
=
false
self
.
user
.
name
=
''
self
.
user
.
email
=
''
self
.
user
.
access_token
=
''
}
else
{
self
.
userOIDC
=
u
self
.
user
.
logged_in
=
true
self
.
user
.
name
=
u
.
profile
.
nickname
self
.
user
.
email
=
u
.
profile
.
email
self
.
user
.
access_token
=
u
.
access_token
console
.
log
(
new
Date
(
u
.
expires_at
*
1000
).
toString
())
console
.
log
(
new
Date
(
u
.
expires_at
*
1000
).
toUTCString
())
console
.
log
(
u
.
access_token
)
self
.
setUserProperties
(
user
)
}
}).
catch
(
function
(
err
)
{
console
.
log
(
err
)
})
},
setUserProperties
(
user
)
{
this
.
userOIDC
=
user
this
.
user
.
logged_in
=
true
this
.
user
.
name
=
user
.
profile
.
nickname
this
.
user
.
email
=
user
.
profile
.
email
this
.
user
.
access_token
=
user
.
access_token
console
.
log
(
new
Date
(
user
.
expires_at
*
1000
).
toString
())
console
.
log
(
new
Date
(
user
.
expires_at
*
1000
).
toUTCString
())
console
.
log
(
user
.
access_token
)
}
},
mounted
()
{
// TODO: remove oidc logging after thorough testing
oidc
.
Log
.
logger
=
console
let
self
=
this
this
.
mgr
.
events
.
addSilentRenewError
(
function
()
{
// TODO: set accessTokenExpiringNotificationTime when this.mgr is created and insert this value here too
this
.
oidc
mgr
.
events
.
addSilentRenewError
(
function
()
{
// TODO: set accessTokenExpiringNotificationTime when this.
oidc
mgr is created and insert this value here too
alert
(
'
Your OpenID access token could not be renewed automatically. You will be logged out in 60 seconds.
'
)
})
this
.
mgr
.
events
.
addAccessTokenExpiring
(
function
()
{
this
.
oidc
mgr
.
events
.
addAccessTokenExpiring
(
function
()
{
console
.
log
(
'
token will soon expire
'
)
console
.
log
(
self
)
/* Use the following code instead of silent renewal if you want to use popups
console.log('starting signinPopup')
self.mgr.signinPopup(function (user) {
self.
oidc
mgr.signinPopup(function (user) {
console.log('signinPopup result for user:')
console.log(user)
}).catch(function (err) {
console.log(err)
})
*/
console
.
log
(
'
starting signinSilent
'
)
self
.
oidcmgr
.
signinSilent
().
then
(
function
(
user
)
{
console
.
log
(
'
signinPopup result for user:
'
)
console
.
log
(
self
.
user
.
access_token
)
self
.
user
.
access_token
=
user
.
access_token
console
.
log
(
self
.
user
.
access_token
)
}).
catch
(
function
(
err
)
{
console
.
log
(
err
)
})
})
this
.
mgr
.
events
.
addAccessTokenExpired
(
function
()
{
this
.
oidc
mgr
.
events
.
addAccessTokenExpired
(
function
()
{
console
.
log
(
'
expired!
'
)
})
this
.
getUser
()
this
.
mgr
.
startSilentRenew
()
this
.
getOIDCUser
()
}
}
</
script
>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment