Skip to content

Commit e9cc674

Browse files
Merge pull request #91 from rubensworks/fix/logout-rp
Fix logout not removing session from RP
2 parents ee07382 + 33a7e47 commit e9cc674

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

src/solid-auth-client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export default class SolidAuthClient extends EventEmitter {
7676
const session = await getSession(storage)
7777
if (session) {
7878
try {
79-
await WebIdOidc.logout(storage)
79+
await WebIdOidc.logout(storage, globalFetch)
8080
this.emit('logout')
8181
this.emit('session', null)
8282
} catch (err) {

src/webid-oidc.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,21 @@ export async function currentSession(
5555
}
5656
}
5757

58-
export async function logout(storage: AsyncStorage): Promise<void> {
58+
export async function logout(
59+
storage: AsyncStorage,
60+
fetch: Function
61+
): Promise<void> {
5962
const rp = await getStoredRp(storage)
6063
if (rp) {
6164
try {
62-
rp.logout()
65+
// First log out from the IDP
66+
await rp.logout()
67+
// Then, log out from the RP
68+
try {
69+
await fetch('/.well-known/solid/logout', { credentials: 'include' })
70+
} catch (e) {
71+
// Ignore errors for when we are not on a Solid pod
72+
}
6373
} catch (err) {
6474
console.warn('Error logging out of the WebID-OIDC session')
6575
console.error(err)

0 commit comments

Comments
 (0)