From 3640cc33633a8f79562fec194c09648c09def6bd Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 30 Apr 2020 14:58:31 +0200 Subject: [PATCH] Redirect on openid error --- peertube-plugin-auth-openid-connect/main.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/peertube-plugin-auth-openid-connect/main.js b/peertube-plugin-auth-openid-connect/main.js index 454ba96..ebe7924 100644 --- a/peertube-plugin-auth-openid-connect/main.js +++ b/peertube-plugin-auth-openid-connect/main.js @@ -192,13 +192,13 @@ async function handleCb (peertubeHelpers, settingsManager, req, res) { if (!store.userAuthenticated) { logger.info('Received callback but cannot userAuthenticated function does not exist.') - return res.sendStatus(400) + return onCBError(res) } const encryptedCodeVerifier = req.cookies[cookieName] if (!encryptedCodeVerifier) { logger.error('Received callback but code verifier not found in request cookie.') - return res.sendStatus(400) + return onCBError(res) } try { @@ -242,10 +242,14 @@ async function handleCb (peertubeHelpers, settingsManager, req, res) { }) } catch (err) { logger.error('Error in handle callback.', { err }) - res.sendStatus(400) + onCBError(res) } } +function onCBError (res) { + res.redirect('/login?externalAuthError=true') +} + async function encrypt (data) { const { algorithm, inputEncoding, outputEncoding } = encryptionOptions