Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Framework
sib-auth
Commits
bc61a363
Commit
bc61a363
authored
Jul 03, 2019
by
Clément
Browse files
use ID Token
parent
8bcf6213
Pipeline
#3254
passed with stage
in 52 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
index.html
View file @
bc61a363
...
...
@@ -10,6 +10,10 @@
sib-test
{
display
:
block
;
}
pre
{
white-space
:
normal
;
word-wrap
:
break-word
;
}
</style>
</head>
<body>
...
...
@@ -70,14 +74,14 @@
async
update
()
{
let
user
=
await
this
.
getUser
();
let
access
Token
=
await
this
.
getUser
Access
Token
();
let
id
Token
=
await
this
.
getUser
Id
Token
();
if
(
!
user
)
{
result
.
innerHTML
=
`Vous n'êtes pas connecté !`
;
return
;
}
user
=
await
store
.
get
(
user
);
console
.
log
(
user
);
result
.
innerHTML
=
`Bonjour
${
user
.
username
}
!<br>
access_token:
${
accessToken
}
`
;
result
.
innerHTML
=
`Bonjour
${
user
.
username
}
!<br>
ID Token: <pre>
${
idToken
}
</pre>
`
;
}
empty
(){}
populate
(){}
...
...
sib-auth.js
View file @
bc61a363
...
...
@@ -55,7 +55,7 @@ class SIBAuth extends HTMLElement {
if
(
!
id
)
return
null
;
return
{
'
@id
'
:
id
};
};
SIBBase
.
prototype
.
getUser
Access
Token
=
()
=>
this
.
getUser
Access
Token
();
SIBBase
.
prototype
.
getUser
Id
Token
=
()
=>
this
.
getUser
Id
Token
();
}
/** @function
...
...
@@ -67,7 +67,7 @@ class SIBAuth extends HTMLElement {
SIBBase
.
prototype
.
login
=
null
;
SIBBase
.
prototype
.
logout
=
null
;
SIBBase
.
prototype
.
getUser
=
null
;
SIBBase
.
prototype
.
getUser
Access
Token
=
null
;
SIBBase
.
prototype
.
getUser
Id
Token
=
null
;
}
/** @function
...
...
@@ -131,7 +131,7 @@ class SIBAuth extends HTMLElement {
/** @function
* @name dispatchUserInfo
* @param {User} userWebId - User
* Try to replace data-src by userWebId iri on [bind-user
WebId
] elements
* Try to replace data-src by userWebId iri on [bind-user] elements
*/
// eslint-disable-next-line class-methods-use-this
async
dispatchUserInfo
()
{
...
...
@@ -146,7 +146,7 @@ class SIBAuth extends HTMLElement {
if
(
document
.
readyState
===
'
loading
'
)
{
document
.
addEventListener
(
'
DOMContentLoaded
'
,
processDOM
);
}
else
{
await
processDOM
();
processDOM
();
}
}
...
...
@@ -169,18 +169,18 @@ class SIBAuth extends HTMLElement {
/** @function
* @name getUser
Access
Token
* Return
Access
Token or undefined
* @name getUser
Id
Token
* Return
Id
Token or undefined
* @return {User}
*/
// eslint-disable-next-line class-methods-use-this
getUser
Access
Token
()
{
getUser
Id
Token
()
{
return
new
Promise
((
resolve
)
=>
{
auth
.
trackSession
((
session
)
=>
{
if
(
!
session
)
{
return
resolve
(
null
);
}
return
resolve
(
session
.
authorization
&&
session
.
authorization
.
access
_token
);
return
resolve
(
session
.
authorization
&&
session
.
authorization
.
id
_token
);
});
});
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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