Skip to content

Commit

Permalink
chore: remove console logs on production
Browse files Browse the repository at this point in the history
  • Loading branch information
kdurek committed Mar 25, 2024
1 parent e0a669a commit cac5c48
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
11 changes: 2 additions & 9 deletions src/app/api/auth/callback/google/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,14 @@ interface GoogleUser {
}

export async function GET(request: Request): Promise<Response> {
console.log('πŸš€ > _____START_CALLBACK_____:');
console.log('πŸš€ > _____PARAMS_____:');
const url = new URL(request.url);
console.log('πŸš€ > url:', url);

const code = url.searchParams.get('code');
console.log('πŸš€ > code:', code);
const state = url.searchParams.get('state');
console.log('πŸš€ > state:', state);
console.log('πŸš€ > _____STORED_____:');

const storedState = cookies().get('google_oauth_state')?.value ?? null;
console.log('πŸš€ > storedState:', storedState);
const storedCodeVerifier = cookies().get('google_oauth_code_verifier')?.value ?? null;
console.log('πŸš€ > storedCodeVerifier:', storedCodeVerifier);

console.log('πŸš€ > _____END_CALLBACK_____:');
if (!code || !state || !storedState || !storedCodeVerifier || state !== storedState) {
return new Response(null, {
status: 400,
Expand Down
12 changes: 0 additions & 12 deletions src/app/api/auth/google/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@ import { cookies } from 'next/headers';
import { google } from '@/server/auth';

export async function GET(): Promise<Response> {
console.log('πŸš€ > _____START_AUTH_____:');
console.log('πŸš€ > _____GENERATED_____:');
const state = generateState();
console.log('πŸš€ > state:', state);
const codeVerifier = generateCodeVerifier();
console.log('πŸš€ > codeVerifier:', codeVerifier);

const url = await google.createAuthorizationURL(state, codeVerifier, {
scopes: ['profile', 'email'],
});
console.log('πŸš€ > url:', url);

cookies().set('google_oauth_state', state, {
path: '/',
Expand All @@ -32,12 +27,5 @@ export async function GET(): Promise<Response> {
sameSite: 'lax',
});

console.log('πŸš€ > _____STORED_____:');
const storedState = cookies().get('google_oauth_state')?.value ?? null;
console.log('πŸš€ > storedState:', storedState);
const storedCodeVerifier = cookies().get('google_oauth_code_verifier')?.value ?? null;
console.log('πŸš€ > storedCodeVerifier:', storedCodeVerifier);
console.log('πŸš€ > _____END_AUTH_____:');

return Response.redirect(url);
}

0 comments on commit cac5c48

Please sign in to comment.