From 12faedf007cc45418f736d8a3e8d289ac435b1d9 Mon Sep 17 00:00:00 2001 From: Kaisa Korpela Date: Mon, 21 Sep 2020 10:22:53 +0300 Subject: [PATCH 1/3] Add logout --- src/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index cd82ec1..59399ef 100644 --- a/src/index.js +++ b/src/index.js @@ -6,7 +6,6 @@ import { db, postTaskEntry, getTaskEntries, - removeMemberTask, deleteActiveTask, postFavouriteTask, getFavouriteTasks, @@ -91,6 +90,11 @@ const main = async () => { }) ) + app.get('/logout', (req, res) => { + req.logout() + res.redirect(clientUrl) + }) + app.post( '/login/callback', passport.authenticate('saml', { From 491eca50c4787a091271c6666557cc49b91c7bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miikka=20Niemela=CC=88?= Date: Tue, 29 Sep 2020 12:28:21 +0300 Subject: [PATCH 2/3] Logout, WIP --- .env.example | 1 + src/index.js | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index adcae6a..0aa0d96 100644 --- a/.env.example +++ b/.env.example @@ -7,3 +7,4 @@ PARTIOID_CALLBACK= ISSUER= CLIENT_URL= METADATA_URL= +LOGOUT_URL= diff --git a/src/index.js b/src/index.js index 59399ef..dbea5cf 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,5 @@ import express from 'express' +import https from 'https' import cors from 'cors' import bodyParser from 'body-parser' import passport from 'passport' @@ -90,10 +91,14 @@ const main = async () => { }) ) - app.get('/logout', (req, res) => { - req.logout() - res.redirect(clientUrl) - }) + app.get( + '/logout', + https.get(process.env.LOGOUT_URL, res => { + res.on('end', () => { + console.log(res) + }) + }) + ) app.post( '/login/callback', @@ -105,6 +110,13 @@ const main = async () => { res.redirect(clientUrl) } ) + + app.post('/logout/callback', async (req, res) => { + req.logout() + req.clearCache() + res.redirect(clientUrl) + }) + app.get('/user', isLoggedIn, async (req, res) => { res.json({ name: `${req.user.firstname} ${req.user.lastname}`, From 148dfc67e8c343b8c9110f42ac830c26de371140 Mon Sep 17 00:00:00 2001 From: Kaisa Korpela Date: Tue, 2 Feb 2021 17:31:24 +0200 Subject: [PATCH 3/3] Edit logout --- .env.example | 1 - src/index.js | 13 ++++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.env.example b/.env.example index 0aa0d96..adcae6a 100644 --- a/.env.example +++ b/.env.example @@ -7,4 +7,3 @@ PARTIOID_CALLBACK= ISSUER= CLIENT_URL= METADATA_URL= -LOGOUT_URL= diff --git a/src/index.js b/src/index.js index 11e3d70..e0b95ef 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,4 @@ import express from 'express' -import https from 'https' import cors from 'cors' import bodyParser from 'body-parser' import passport from 'passport' @@ -93,14 +92,10 @@ const main = async () => { }) ) - app.get( - '/logout', - https.get(process.env.LOGOUT_URL, res => { - res.on('end', () => { - console.log(res) - }) - }) - ) + app.get('/logout', function(req, res) { + req.logout() + res.redirect(clientUrl) + }) app.post( '/login/callback',