Skip to content

Commit 1373b33

Browse files
Implement logout()
1 parent 0e2e201 commit 1373b33

4 files changed

Lines changed: 21 additions & 93 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ node_modules
3535
# Build dirs
3636
lib
3737
dist
38+
demo/solid-client.min.js*
39+

demo/index.html

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ <h5>App body</h5>
6464
document.addEventListener('DOMContentLoaded', function () {
6565
window.addEventListener('message', onMessage)
6666
init()
67-
SolidClient.auth.currentUser()
67+
SolidClient.currentUser()
6868
.then(function (webId) {
6969
loginSuccess(webId)
7070
})
@@ -85,7 +85,7 @@ <h5>App body</h5>
8585
}
8686

8787
function loginTo (providerUri) {
88-
SolidClient.auth.login(providerUri)
88+
SolidClient.login(providerUri)
8989
.then(function (webId) {
9090
loginSuccess(webId)
9191
})
@@ -110,7 +110,15 @@ <h5>App body</h5>
110110
}
111111

112112
function logout () {
113-
alert('logging out')
113+
SolidClient.logout()
114+
.then(function () {
115+
console.log('logged out')
116+
hide('logoutDiv')
117+
setField('webId', SolidClient.auth.webId)
118+
})
119+
.catch(function (err) {
120+
console.error('Error logging out: ', err)
121+
})
114122
}
115123

116124
function getRootAcl () {

demo/solid-client.min.js

Lines changed: 0 additions & 90 deletions
This file was deleted.

src/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,14 @@ class ClientAuthOIDC {
192192
this.idToken = null
193193
}
194194

195+
logout () {
196+
this.clearCurrentUser()
197+
if (!this.currentClient) {
198+
return Promise.resolve(null)
199+
}
200+
return this.currentClient.logout()
201+
}
202+
195203
/**
196204
* Resolves to the URI of an OIDC identity provider, from one of the following:
197205
*

0 commit comments

Comments
 (0)