From 7fd9a4e46ad67d7c260acf057d1125c26e86f592 Mon Sep 17 00:00:00 2001 From: Avris Date: Fri, 3 Dec 2021 17:49:14 +0100 Subject: [PATCH] [auth] oauth - handle subdomains - include unpublished versions --- server/routes/user.js | 2 +- src/helpers.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/routes/user.js b/server/routes/user.js index 0898994e..d25a16f9 100644 --- a/server/routes/user.js +++ b/server/routes/user.js @@ -439,7 +439,7 @@ router.get('/user/social/:provider', handleErrorAsync(async (req, res) => { if (!req.session.socialRedirect) { return '/' + config.user.route; } - const host = buildLocaleList(config.locale)[req.session.socialRedirect].url; + const host = buildLocaleList(config.locale, true)[req.session.socialRedirect].url; delete req.session.socialRedirect; return `${host}/api/user/social-redirect-callback/${encodeURIComponent(token)}`; diff --git a/src/helpers.js b/src/helpers.js index fbc578be..9f217f02 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -149,10 +149,10 @@ export const isTroll = (body) => { return ['cipeusz', 'feminazi', 'bruksela', 'zboczeń'].some(t => body.indexOf(t) > -1); } -export const buildLocaleList = (current) => { +export const buildLocaleList = (current, includeUnpublished = false) => { return buildDict(function* () { for (let [code, name, url, published] of locales) { - if (published || current === code) { + if (published || current === code || includeUnpublished) { yield [code, {name, url, published}]; } }