From 6f68f4d20ad2c25e3a6aae7fd805f8d6362e69de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 2 Dec 2020 12:42:21 -0500 Subject: [PATCH] fix: #9032, fix login redirect for sso plugins --- public/src/ajaxify.js | 16 ++++++---------- src/controllers/index.js | 7 +------ 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index 76b1a545ba..07f44c19b8 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -155,16 +155,12 @@ ajaxify = window.ajaxify || {}; app.alertError('[[global:please_log_in]]'); app.previousUrl = url; window.location.href = config.relative_path + '/login'; - } else if (status === 302 || status === 308) { - if (data.responseJSON && data.responseJSON.external) { - window.location.href = data.responseJSON.external; - } else if (typeof data.responseJSON === 'string') { - ajaxifyTimer = undefined; - if (data.responseJSON.startsWith('http://') || data.responseJSON.startsWith('https://')) { - window.location.href = data.responseJSON; - } else { - ajaxify.go(data.responseJSON.slice(1), callback, quiet); - } + } else if ((status === 302 || status === 308) && typeof data.responseJSON === 'string') { + ajaxifyTimer = undefined; + if (data.responseJSON.startsWith('http://') || data.responseJSON.startsWith('https://')) { + window.location.href = data.responseJSON; + } else { + ajaxify.go(data.responseJSON.slice(1), callback, quiet); } } } else if (textStatus !== 'abort') { diff --git a/src/controllers/index.js b/src/controllers/index.js index 18f9ea3820..caa2f7311a 100644 --- a/src/controllers/index.js +++ b/src/controllers/index.js @@ -125,12 +125,7 @@ Controllers.login = async function (req, res) { data.allowLocalLogin = hasLoginPrivilege || parseInt(req.query.local, 10) === 1; if (!data.allowLocalLogin && !data.allowRegistration && data.alternate_logins && data.authentication.length === 1) { - if (res.locals.isAPI) { - return helpers.redirect(res, { - external: nconf.get('relative_path') + data.authentication[0].url, - }); - } - return res.redirect(nconf.get('relative_path') + data.authentication[0].url); + return helpers.redirect(res, data.authentication[0].url); } if (req.loggedIn) {