Skip to content

Commit 8071d4d

Browse files
committed
Trigger logout route when you log out
1 parent 1b1c630 commit 8071d4d

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

src/authn/authn.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,7 @@ export function renderSignInPopup (dom: HTMLDocument) {
988988
if (preLoginRedirectHash) {
989989
window.localStorage.setItem('preLoginRedirectHash', preLoginRedirectHash)
990990
}
991+
window.localStorage.setItem('loginIssuer', issuerUri)
991992
// Login
992993
await authSession.login({
993994
redirectUrl: window.location.href,
@@ -1243,7 +1244,23 @@ export function loginStatusBox (
12431244
return box
12441245
}
12451246

1246-
authSession.onLogout(() => {
1247+
authSession.onLogout(async () => {
1248+
const issuer = window.localStorage.getItem('loginIssuer')
1249+
if (issuer) {
1250+
try {
1251+
const wellKnownUri = new URL(issuer)
1252+
wellKnownUri.pathname = '/.well-known/openid-configuration'
1253+
const wellKnownResult = await fetch(wellKnownUri.toString())
1254+
if (wellKnownResult.status === 200) {
1255+
const openidConfiguration = await wellKnownResult.json()
1256+
if (openidConfiguration && openidConfiguration.end_session_endpoint) {
1257+
await fetch(openidConfiguration.end_session_endpoint)
1258+
}
1259+
}
1260+
} catch (err) {
1261+
// Do nothing
1262+
}
1263+
}
12471264
window.location.reload()
12481265
})
12491266

src/header/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This file was copied from mashlib/src/global/header.ts file. It is modified to
44
work in solid-ui by adjusting where imported functions are found.
55
*/
6-
import { IndexedFormula, NamedNode, sym } from 'rdflib'
6+
import { IndexedFormula, NamedNode } from 'rdflib'
77
import { loginStatusBox, authSession, currentUser } from '../authn/authn'
88
import * as widgets from '../widgets'
99
import { emptyProfile } from './empty-profile'

0 commit comments

Comments
 (0)