Skip to content

Commit 316100c

Browse files
Implement single logout
1 parent ef59230 commit 316100c

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

index.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,16 @@ app.get("/analytics", restrict, function (req, res) {
140140
});
141141

142142
app.get("/logout", function (req, res) {
143-
// destroy the user's session to log them out
144-
// will be re-created next request
145-
req.session.destroy(function () {
146-
res.redirect("/");
147-
});
143+
const mbLogoutUrl = new URL("/auth/logout", METABASE_SITE_URL);
144+
145+
// destroy the user's session to log them out
146+
// will be re-created next request
147+
req.session.destroy(function () {
148+
// sign user out of Metabase by loading /auth/logout in a hidden iframe
149+
res.send(`
150+
You have been logged out. <a href="/login">Log in</a>
151+
<iframe src="${mbLogoutUrl}" hidden></iframe>`);
152+
});
148153
});
149154

150155
app.get("/login", function (req, res) {

0 commit comments

Comments
 (0)