From c15051462ec53213c24487e16d008d6b6811164e Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Wed, 7 Jul 2021 13:28:55 +0100 Subject: [PATCH] Add info to 403 responses --- packages/worker/src/api/controllers/admin/auth.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/worker/src/api/controllers/admin/auth.js b/packages/worker/src/api/controllers/admin/auth.js index 3c0f76c575..01717bffe0 100644 --- a/packages/worker/src/api/controllers/admin/auth.js +++ b/packages/worker/src/api/controllers/admin/auth.js @@ -11,16 +11,16 @@ const { checkResetPasswordCode } = require("../../../utilities/redis") const GLOBAL_DB = authPkg.StaticDatabases.GLOBAL.name -function authInternal(ctx, user, err = null) { +function authInternal(ctx, user, err = null, info = null) { if (err) { - return ctx.throw(403, "Unauthorized") + return ctx.throw(403, info? info : "Unauthorized") } const expires = new Date() expires.setDate(expires.getDate() + 1) if (!user) { - return ctx.throw(403, "Unauthorized") + return ctx.throw(403, info? info : "Unauthorized") } ctx.cookies.set(Cookies.Auth, user.token, { @@ -154,8 +154,8 @@ exports.oidcAuth = async (ctx, next) => { return passport.authenticate( strategy, { successRedirect: "/", failureRedirect: "/error" }, - async (err, user) => { - authInternal(ctx, user, err) + async (err, user, info) => { + authInternal(ctx, user, err, info) ctx.redirect("/") }