Skip to content

Commit

Permalink
asd
Browse files Browse the repository at this point in the history
  • Loading branch information
Bit-Barron committed Nov 2, 2024
1 parent ad78846 commit a38e8d4
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 94 deletions.
23 changes: 0 additions & 23 deletions src/lib/server/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
}
16 changes: 12 additions & 4 deletions src/lib/server/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ export const initSocketIO = (httpServer: HTTPServer): Promise<Server> => {
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) => {
Expand All @@ -29,8 +33,12 @@ export const initSocketIO = (httpServer: HTTPServer): Promise<Server> => {
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);
});
});

Expand Down
3 changes: 1 addition & 2 deletions src/lib/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
16 changes: 0 additions & 16 deletions src/routes/(auth)/login/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,6 @@
<a href="/register" class="underline">{$_('sign-up')}</a>
</div>
<Button type="submit" class="w-full">{$_('login')}</Button>
<div class="relative flex items-center justify-center">
<Separator.Root class="shrink" />
<span class="px-2 text-xs text-muted-foreground">{$_('or')}</span>
<Separator.Root class="shrink" />
</div>
<button
on:click={() => goto('/login/google')}
class="flex h-9 w-full items-center justify-center gap-2 rounded-md border border-gray-300 bg-white px-3 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-50 focus:outline-none focus:ring-4 focus:ring-[#4285F4]/50"
>
<img
src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMTgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNMTcuNiA5LjJsLS4xLTEuOEg5djMuNGg0LjhDMTMuNiAxMiAxMyAxMyAxMiAxMy42djIuMmgzYTguOCA4LjggMCAwIDAgMi42LTYuNnoiIGZpbGw9IiM0Mjg1RjQiIGZpbGwtcnVsZT0ibm9uemVybyIvPjxwYXRoIGQ9Ik05IDE4YzIuNCAwIDQuNS0uOCA2LTIuMmwtMy0yLjJhNS40IDUuNCAwIDAgMS04LTIuOUgxVjEzYTkgOSAwIDAgMCA4IDV6IiBmaWxsPSIjMzRBODUzIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48cGF0aCBkPSJNNCAxMC43YTUuNCA1LjQgMCAwIDEgMC0zLjRWNUgxYTkgOSAwIDAgMCAwIDhsMy0yLjN6IiBmaWxsPSIjRkJCQzA1IiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48cGF0aCBkPSJNOSAzLjZjMS4zIDAgMi41LjQgMy40IDEuM0wxNSAyLjNBOSA5IDAgMCAwIDEgNWwzIDIuNGE1LjQgNS40IDAgMCAxIDUtMy43eiIgZmlsbD0iI0VBNDMzNSIgZmlsbC1ydWxlPSJub256ZXJvIi8+PHBhdGggZD0iTTAgMGgxOHYxOEgweiIvPjwvZz48L3N2Zz4="
alt="Google logo"
class="h-5 w-5"
/>
<span>{$_('sign-in-with-google')}</span>
</button>
</div>
</form>
</Card.Content>
Expand Down
31 changes: 0 additions & 31 deletions src/routes/(auth)/login/google/+server.ts

This file was deleted.

18 changes: 0 additions & 18 deletions src/routes/(auth)/register/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -71,23 +70,6 @@
Create an account
{/if}
</Button>
<div class="relative flex items-center justify-center">
<Separator.Root class="shrink" />
<span class="px-2 text-xs text-muted-foreground">OR</span>
<Separator.Root class="shrink" />
</div>
<button
on:click={() => goto('/login/google')}
class="flex h-9 w-full items-center justify-center gap-2 rounded-md border border-gray-300 bg-white px-3 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-50 focus:outline-none focus:ring-4 focus:ring-[#4285F4]/50"
disabled={isLoading}
>
<img
src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMTgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNMTcuNiA5LjJsLS4xLTEuOEg5djMuNGg0LjhDMTMuNiAxMiAxMyAxMyAxMiAxMy42djIuMmgzYTguOCA4LjggMCAwIDAgMi42LTYuNnoiIGZpbGw9IiM0Mjg1RjQiIGZpbGwtcnVsZT0ibm9uemVybyIvPjxwYXRoIGQ9Ik05IDE4YzIuNCAwIDQuNS0uOCA2LTIuMmwtMy0yLjJhNS40IDUuNCAwIDAgMS04LTIuOUgxVjEzYTkgOSAwIDAgMCA4IDV6IiBmaWxsPSIjMzRBODUzIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48cGF0aCBkPSJNNCAxMC43YTUuNCA1LjQgMCAwIDEgMC0zLjRWNUgxYTkgOSAwIDAgMCAwIDhsMy0yLjN6IiBmaWxsPSIjRkJCQzA1IiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48cGF0aCBkPSJNOSAzLjZjMS4zIDAgMi41LjQgMy40IDEuM0wxNSAyLjNBOSA5IDAgMCAwIDEgNWwzIDIuNGE1LjQgNS40IDAgMCAxIDUtMy43eiIgZmlsbD0iI0VBNDMzNSIgZmlsbC1ydWxlPSJub256ZXJvIi8+PHBhdGggZD0iTTAgMGgxOHYxOEgweiIvPjwvZz48L3N2Zz4="
alt="Google logo"
class="h-5 w-5"
/>
<span>{$_('sign-in-with-google')}</span>
</button>
</div>
</form>
</Card.Content>
Expand Down

0 comments on commit a38e8d4

Please sign in to comment.