Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add error logs to auth callbacks #1607

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export default async function handler(req: NextRequest): Promise<NextResponse> {
const redirectLocation = state ?? `https://${domain}/`;

if (edgeConfig?.type !== "basic_token_verification" || token == null) {
// eslint-disable-next-line no-console
console.error(`Invalid config for domain ${domain}`);
return redirectWithLoginError(redirectLocation, "Couldn't login, please try again");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,22 @@ export default async function GET(req: NextRequest): Promise<NextResponse> {
const redirectLocation = state ?? `https://${domain}/`;

if (error != null) {
// eslint-disable-next-line no-console
console.error(`OAuth2 error: ${error} - ${error_description}`);
return redirectWithLoginError(redirectLocation, error_description ?? error);
}

if (typeof code !== "string") {
// eslint-disable-next-line no-console
console.error("Missing code in query params");
return redirectWithLoginError(redirectLocation, "Couldn't login, please try again");
}

const config = await getAuthEdgeConfig(domain);

if (config == null || config.type !== "oauth2" || config.partner !== "ory") {
// eslint-disable-next-line no-console
console.log(`Invalid config for domain ${domain}`);
return redirectWithLoginError(redirectLocation, "Couldn't login, please try again");
}

Expand All @@ -64,7 +70,7 @@ export default async function GET(req: NextRequest): Promise<NextResponse> {
return res;
} catch (error) {
// eslint-disable-next-line no-console
console.error(error);
console.error("Error getting access token", error);
return redirectWithLoginError(redirectLocation, "Couldn't login, please try again");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,22 @@ export default async function GET(req: NextRequest): Promise<NextResponse> {
const redirectLocation = state ?? `https://${domain}/`;

if (error != null) {
// eslint-disable-next-line no-console
console.error(`OAuth2 error: ${error} - ${error_description}`);
return redirectWithLoginError(redirectLocation, error_description ?? error);
}

if (typeof code !== "string") {
// eslint-disable-next-line no-console
console.error("Missing code in query params");
return redirectWithLoginError(redirectLocation, "Couldn't login, please try again");
}

const config = await getAuthEdgeConfig(domain);

if (config == null || config.type !== "oauth2" || config.partner === "ory") {
if (config == null || config.type !== "oauth2" || config.partner === "webflow") {
// eslint-disable-next-line no-console
console.log(`Invalid config for domain ${domain}`);
return redirectWithLoginError(redirectLocation, "Couldn't login, please try again");
}

Expand All @@ -52,7 +58,7 @@ export default async function GET(req: NextRequest): Promise<NextResponse> {
return res;
} catch (error) {
// eslint-disable-next-line no-console
console.error(error);
console.error("Error getting access token", error);
return redirectWithLoginError(redirectLocation, "Couldn't login, please try again");
}
}
Loading