Skip to content

Commit

Permalink
chore: add error logs to auth
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity committed Oct 8, 2024
1 parent 365c1e6 commit 1289bab
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
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");
}
}

0 comments on commit 1289bab

Please sign in to comment.