Add additional debug logging to no user OIDC case

Related #5241
This commit is contained in:
Tom Moor
2023-05-01 20:23:35 -04:00
parent 5ee6cdb2ca
commit 7d7781d795

View File

@@ -1,6 +1,7 @@
import passport from "@outlinewiki/koa-passport";
import { Context } from "koa";
import env from "@server/env";
import { AuthenticationError } from "@server/errors";
import Logger from "@server/logging/Logger";
import { AuthenticationResult } from "@server/types";
import { signIn } from "@server/utils/authentication";
@@ -55,7 +56,11 @@ export default function createMiddleware(providerName: string) {
// the event that error=access_denied is received from the OAuth server.
// I'm not sure why this exception to the rule exists, but it does:
// https://github.com/jaredhanson/passport-oauth2/blob/e20f26aad60ed54f0e7952928cbb64979ef8da2b/lib/strategy.js#L135
if (!user) {
if (!user && !result?.user) {
Logger.error(
"No user returned during authentication",
AuthenticationError()
);
return ctx.redirect(`/?notice=auth-error`);
}