Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
SiB Auth
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
15
Issues
15
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Startin blox
framework
SiB Auth
Commits
2ec5b638
Commit
2ec5b638
authored
Jul 11, 2019
by
Matthieu Fesselier
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'sib-core-v0.8' into 'master'
update: use sib-core v0.8 See merge request
!13
parents
eabebab5
455ff77d
Pipeline
#4523
passed with stage
in 52 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
21 deletions
+20
-21
index.html
index.html
+7
-7
sib-auth.js
sib-auth.js
+13
-14
No files found.
index.html
View file @
2ec5b638
...
...
@@ -68,9 +68,9 @@
</script>
<script
type=
"module"
>
import
{
SIBBase
,
store
}
from
'
https://unpkg.com/@startinblox/core@0.7
'
;
class
TestComponent
extends
SIBBase
{
import
{
store
}
from
'
https://unpkg.com/@startinblox/core@0.8
'
;
const
sibAuth
=
document
.
querySelector
(
'
sib-auth
'
);
class
TestComponent
extends
HTMLElement
{
async
connectedCallback
()
{
login
.
onclick
=
()
=>
this
.
triggerLogin
();
logout
.
onclick
=
()
=>
this
.
triggerLogout
();
...
...
@@ -79,15 +79,15 @@
}
async
triggerLogin
()
{
await
this
.
login
();
await
sibAuth
.
login
();
}
async
triggerLogout
()
{
await
this
.
logout
();
await
sibAuth
.
logout
();
}
async
update
()
{
let
user
=
await
this
.
getUser
();
let
idToken
=
await
this
.
getUserIdToken
();
let
user
=
await
sibAuth
.
getUser
();
let
idToken
=
await
sibAuth
.
getUserIdToken
();
if
(
!
user
)
{
result
.
innerHTML
=
`Vous n'êtes pas connecté !`
;
return
;
...
...
sib-auth.js
View file @
2ec5b638
import
auth
from
'
https://dev.jspm.io/solid-auth-client
'
;
import
{
Helpers
,
SIBBase
}
from
'
https://unpkg.com/@startinblox/core@0.7
'
;
import
{
Helpers
}
from
'
https://unpkg.com/@startinblox/core@0.8
'
;
const
baseUrl
=
import
.
meta
.
url
.
replace
(
/
\/[^/]
*$/
,
''
);
Helpers
.
importCSS
(
`
${
baseUrl
}
/sib-auth.css`
);
...
...
@@ -48,14 +48,6 @@ class SIBAuth extends HTMLElement {
* to provide auth information on all SIB component
*/
install
()
{
SIBBase
.
prototype
.
login
=
()
=>
this
.
login
();
SIBBase
.
prototype
.
logout
=
()
=>
this
.
logout
();
SIBBase
.
prototype
.
getUserIdToken
=
()
=>
this
.
getUserIdToken
();
SIBBase
.
prototype
.
getUser
=
async
()
=>
{
const
id
=
await
this
.
getUserWebId
();
if
(
!
id
)
return
null
;
return
{
'
@id
'
:
id
};
};
this
.
bindUserObserver
=
new
MutationObserver
((
mutations
)
=>
{
mutations
.
forEach
((
mutation
)
=>
{
if
(
mutation
.
type
===
'
attributes
'
)
{
...
...
@@ -86,10 +78,6 @@ class SIBAuth extends HTMLElement {
*/
// eslint-disable-next-line class-methods-use-this
uninstall
()
{
SIBBase
.
prototype
.
login
=
null
;
SIBBase
.
prototype
.
logout
=
null
;
SIBBase
.
prototype
.
getUser
=
null
;
SIBBase
.
prototype
.
getUserIdToken
=
null
;
this
.
bindUserObserver
.
disconnect
();
}
...
...
@@ -201,7 +189,7 @@ class SIBAuth extends HTMLElement {
/** @function
* @name getUserIdToken
* Return IdToken or
undefined
* Return IdToken or
null
* @return {User}
*/
// eslint-disable-next-line class-methods-use-this
...
...
@@ -216,6 +204,17 @@ class SIBAuth extends HTMLElement {
});
}
/** @function
* @name getUser
* Return user or null
* @return {User}
*/
async
getUser
()
{
const
id
=
await
this
.
getUserWebId
();
if
(
!
id
)
return
null
;
return
{
'
@id
'
:
id
};
}
/** @function
* @name login
* Try to login, if favorite provider is set, trigger login, if not, select provider
...
...
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