Add error logging for user save failure in sso authentication

This commit is contained in:
Rory Powell 2023-02-15 14:53:38 +00:00
parent c41c96e980
commit 65ee7169f8
2 changed files with 6 additions and 3 deletions

View File

@ -94,7 +94,7 @@ export async function authenticateThirdParty(
try {
await saveUserFn(dbUser, { hashPassword: false, requirePassword: false })
} catch (err: any) {
return authError(done, err)
return authError(done, "Error saving user", err)
}
// now that we're sure user exists, load them from the db

View File

@ -27,13 +27,16 @@ export async function oidcCallbackUrl(config?: { callbackURL?: string }) {
return ssoCallbackUrl(tenancy.getGlobalDB(), config, ConfigType.OIDC)
}
async function authInternal(ctx: any, user: any, err = null, info = null) {
async function authInternal(ctx: any, user: any, err: any = null, info = null) {
if (err) {
console.error("Authentication error", err)
console.error("Authentication error")
console.error(err)
console.trace(err)
return ctx.throw(403, info ? info : "Unauthorized")
}
if (!user) {
console.error("Authentication error - no user provided")
return ctx.throw(403, info ? info : "Unauthorized")
}