diff --git a/src/lib/server/auth.ts b/src/lib/server/auth.ts index a4d4fb3..e09f2d8 100644 --- a/src/lib/server/auth.ts +++ b/src/lib/server/auth.ts @@ -2,7 +2,6 @@ import { Lucia } from 'lucia'; import { dev } from '$app/environment'; import { PrismaAdapter } from '@lucia-auth/adapter-prisma'; import client from '../utils/prisma'; -import { Google } from 'arctic'; const adapter = new PrismaAdapter(client.session, client.user); @@ -29,25 +28,3 @@ declare module 'lucia' { interface DatabaseUserAttributes { email: string; } - -function createGoogleAuth() { - if (dev || !process.env.GOOGLE_CLIENT_ID || !process.env.GOOGLE_CLIENT_SECRET) { - return new Google( - process.env.GOOGLE_CLIENT_ID || 'dummy-id', - process.env.GOOGLE_CLIENT_SECRET || 'dummy-secret', - 'http://localhost:5173/auth/callback/google' - ); - } - - return new Google( - process.env.GOOGLE_CLIENT_ID, - process.env.GOOGLE_CLIENT_SECRET, - 'http://localhost:5173/auth/callback/google' - ); -} - -export const google = createGoogleAuth(); - -export function isGoogleAuthConfigured(): boolean { - return Boolean(process.env.GOOGLE_CLIENT_ID && process.env.GOOGLE_CLIENT_SECRET); -} diff --git a/src/lib/server/socket.ts b/src/lib/server/socket.ts index 6b90ac5..4cb6ea3 100644 --- a/src/lib/server/socket.ts +++ b/src/lib/server/socket.ts @@ -11,13 +11,17 @@ export const initSocketIO = (httpServer: HTTPServer): Promise => { if (!io) { console.log('Initializing Socket.IO server...'); io = new Server(httpServer, { - path: '/socket.io', + path: '/socket.io/', cors: { origin: dev ? ['http://localhost:3000'] : ['https://youtubepedia.barron.agency'], methods: ['GET', 'POST'], credentials: true }, - transports: ['websocket', 'polling'] + transports: ['websocket', 'polling'], + pingTimeout: 60000, + pingInterval: 25000, + connectTimeout: 45000, + allowEIO3: true }); io.on('connection', (socket) => { @@ -29,8 +33,12 @@ export const initSocketIO = (httpServer: HTTPServer): Promise => { console.log(`User ${userId} joined their room`); } - socket.on('disconnect', () => { - console.log('Client disconnected', socket.id); + socket.on('error', (error) => { + console.error('Socket error:', error); + }); + + socket.on('disconnect', (reason) => { + console.log(`Client disconnected (${reason})`, socket.id); }); }); diff --git a/src/lib/socket.ts b/src/lib/socket.ts index 5ba1b9e..3a70b57 100644 --- a/src/lib/socket.ts +++ b/src/lib/socket.ts @@ -9,8 +9,7 @@ export const initSocket = (userId: string): Socket | null => { auth: { userId }, reconnection: true, reconnectionDelay: 1000, - reconnectionAttempts: 5, - path: '/socket.io' + reconnectionAttempts: 5 }); socket.on('connect', () => { diff --git a/src/routes/(auth)/login/+page.svelte b/src/routes/(auth)/login/+page.svelte index 49d6c85..3c196ff 100644 --- a/src/routes/(auth)/login/+page.svelte +++ b/src/routes/(auth)/login/+page.svelte @@ -70,22 +70,6 @@ {$_('sign-up')} -
- - {$_('or')} - -
- diff --git a/src/routes/(auth)/login/google/+server.ts b/src/routes/(auth)/login/google/+server.ts deleted file mode 100644 index 008d5d3..0000000 --- a/src/routes/(auth)/login/google/+server.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { google } from '$lib/server/auth'; -import { redirect } from '@sveltejs/kit'; -import type { RequestEvent } from '../$types'; -import { generateCodeVerifier, generateState } from 'arctic'; - -export async function GET(event: RequestEvent): Promise { - const state = generateState(); - const codeVerifier = generateCodeVerifier(); - - const scopes = ['email', 'profile']; - - const url = google.createAuthorizationURL(state, codeVerifier, scopes); - - event.cookies.set('google_oauth_state', state, { - httpOnly: true, - path: '/', - secure: true, - maxAge: 60 * 60, - sameSite: 'lax' - }); - - event.cookies.set('google_oauth_code_verifier', codeVerifier, { - httpOnly: true, - path: '/', - secure: true, - maxAge: 60 * 60, - sameSite: 'lax' - }); - - return redirect(302, url.toString()); -} diff --git a/src/routes/(auth)/register/+page.svelte b/src/routes/(auth)/register/+page.svelte index a16944c..365cd55 100644 --- a/src/routes/(auth)/register/+page.svelte +++ b/src/routes/(auth)/register/+page.svelte @@ -33,7 +33,6 @@ if (result.type === 'success') { toast.success('Account created successfully!'); - // The redirect in the server will handle navigation } if (result.type === 'error') { @@ -71,23 +70,6 @@ Create an account {/if} -
- - OR - -
-