Add info to 403 responses
This commit is contained in:
parent
0745eedbcc
commit
42c8526ac2
|
@ -11,16 +11,16 @@ const { checkResetPasswordCode } = require("../../../utilities/redis")
|
||||||
|
|
||||||
const GLOBAL_DB = authPkg.StaticDatabases.GLOBAL.name
|
const GLOBAL_DB = authPkg.StaticDatabases.GLOBAL.name
|
||||||
|
|
||||||
function authInternal(ctx, user, err = null) {
|
function authInternal(ctx, user, err = null, info = null) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return ctx.throw(403, "Unauthorized")
|
return ctx.throw(403, info? info : "Unauthorized")
|
||||||
}
|
}
|
||||||
|
|
||||||
const expires = new Date()
|
const expires = new Date()
|
||||||
expires.setDate(expires.getDate() + 1)
|
expires.setDate(expires.getDate() + 1)
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return ctx.throw(403, "Unauthorized")
|
return ctx.throw(403, info? info : "Unauthorized")
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.cookies.set(Cookies.Auth, user.token, {
|
ctx.cookies.set(Cookies.Auth, user.token, {
|
||||||
|
@ -154,8 +154,8 @@ exports.oidcAuth = async (ctx, next) => {
|
||||||
return passport.authenticate(
|
return passport.authenticate(
|
||||||
strategy,
|
strategy,
|
||||||
{ successRedirect: "/", failureRedirect: "/error" },
|
{ successRedirect: "/", failureRedirect: "/error" },
|
||||||
async (err, user) => {
|
async (err, user, info) => {
|
||||||
authInternal(ctx, user, err)
|
authInternal(ctx, user, err, info)
|
||||||
|
|
||||||
ctx.redirect("/")
|
ctx.redirect("/")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue