From 29f6c5616114763cd753c4087299b5bd7908fe4e Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Thu, 8 Aug 2019 16:40:16 +0300 Subject: [PATCH] slight oversight #3 --- server/routes/api.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server/routes/api.js b/server/routes/api.js index 45cce29..fa689c2 100644 --- a/server/routes/api.js +++ b/server/routes/api.js @@ -99,7 +99,7 @@ function removeAuthMiddleware (identifier) { * No tokens saved in configs, everything works out-of-the-box */ router.post('/external/facebook/callback', wrap(async (req, res, next) => { - if (!config.facebook || !config.facebook.client) return next() + if (!config.external || !config.external.facebook || !config.external.facebook.client) return next() // Fix up the retarded object Facebook sends us let sane = objectAssembler(req.body) @@ -133,7 +133,7 @@ router.get('/external/facebook/remove', removeAuthMiddleware('facebook')) * Tokens in configs */ router.get('/external/twitter/login', wrap(async (req, res) => { - if (!config.twitter || !config.twitter.api) return res.redirect('/') + if (!config.external || !config.external.twitter || !config.external.twitter.api) return res.redirect('/') let tokens = await APIExtern.Twitter.getRequestToken() if (tokens.error) { @@ -146,7 +146,7 @@ router.get('/external/twitter/login', wrap(async (req, res) => { })) router.get('/external/twitter/callback', wrap(async (req, res) => { - if (!config.twitter || !config.twitter.api) return res.redirect('/login') + if (!config.external || !config.external.twitter || !config.external.twitter.api) return res.redirect('/login') if (!req.session.twitter_auth) return res.redirect('/login') let ta = req.session.twitter_auth let uri = '/login' @@ -189,7 +189,7 @@ router.get('/external/twitter/remove', removeAuthMiddleware('twitter')) * Tokens in configs */ router.get('/external/discord/login', wrap(async (req, res) => { - if (!config.discord || !config.discord.api) return res.redirect('/') + if (!config.external || !config.external.discord || !config.external.discord.api) return res.redirect('/') let infos = APIExtern.Discord.getAuthorizeURL(req) @@ -197,7 +197,7 @@ router.get('/external/discord/login', wrap(async (req, res) => { })) router.get('/external/discord/callback', wrap(async (req, res) => { - if (!config.discord || !config.discord.api) return res.redirect('/login') + if (!config.external || !config.external.discord || !config.external.discord.api) return res.redirect('/login') let code = req.query.code let state = req.query.state @@ -246,13 +246,13 @@ router.get('/external/discord/remove', removeAuthMiddleware('discord')) * Tokens in configs */ router.get('/external/google/login', wrap(async (req, res) => { - if (!config.google || !config.google.api) return res.redirect('/') + if (!config.external || !config.external.google || !config.external.google.api) return res.redirect('/') res.redirect('/login') })) router.post('/external/google/callback', wrap(async (req, res) => { - if (!config.google || !config.google.api) return res.redirect('/login') + if (!config.external || !config.external.google || !config.external.google.api) return res.redirect('/login') if (!req.body.id_token) { return JsonData(req, res, 'Invalid or missing ID token!', '/login')