From c8a032a16efbc875efefae8b416d5abadb2db582 Mon Sep 17 00:00:00 2001 From: Luke Hagar Date: Wed, 28 May 2025 13:37:54 -0500 Subject: [PATCH] adding logs --- src/hooks.server.ts | 4 +- src/routes/auth/+page.svelte | 108 ++++++++++++------- src/routes/auth/reset-password/+page.svelte | 49 ++++++--- src/routes/auth/update-password/+page.svelte | 67 +++++++----- 4 files changed, 148 insertions(+), 80 deletions(-) diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 8954dfa..2eb3d5d 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -67,10 +67,12 @@ const authGuard: Handle = async ({ event, resolve }) => { event.locals.session = session; event.locals.user = user; + console.log(event.locals); + // Protect routes that require authentication if (event.url.pathname.startsWith('/app')) { if (!session) { - throw redirect(303, '/auth/login'); + throw redirect(303, '/auth'); } } diff --git a/src/routes/auth/+page.svelte b/src/routes/auth/+page.svelte index ad5a25e..da0aee0 100644 --- a/src/routes/auth/+page.svelte +++ b/src/routes/auth/+page.svelte @@ -2,7 +2,7 @@ import { supabase } from '$lib/supabaseClient'; import { goto } from '$app/navigation'; import { toaster } from '$lib'; - import { Mail, Lock, LogIn, UserPlus, Github, Chrome, MessageCircle, Twitter, Star, Eye, EyeOff } from '@lucide/svelte'; + import { Mail, Lock, LogIn, UserPlus, Github, Chrome, MessageCircle, Twitter, Star, Eye, EyeOff, AlertTriangle } from '@lucide/svelte'; import { onMount } from 'svelte'; let activeTab = $state('login'); // 'login' or 'signup' @@ -26,40 +26,55 @@ let oauthLoading = $state(''); let message = $state(''); - // OAuth providers configuration + // OAuth providers configuration - only GitHub enabled for demo const oauthProviders = [ { name: 'GitHub', provider: 'github', icon: Github, color: 'bg-[#333] hover:bg-[#555] text-white', - description: 'Continue with GitHub' + description: 'Continue with GitHub', + enabled: true }, { name: 'Google', provider: 'google', icon: Chrome, - color: 'bg-white hover:bg-gray-50 text-gray-900 border border-gray-300', - description: 'Continue with Google' + color: 'bg-gray-300 text-gray-500 cursor-not-allowed', + description: 'Continue with Google (Demo Disabled)', + enabled: false }, { name: 'Discord', provider: 'discord', icon: MessageCircle, - color: 'bg-[#5865F2] hover:bg-[#4752C4] text-white', - description: 'Continue with Discord' + color: 'bg-gray-300 text-gray-500 cursor-not-allowed', + description: 'Continue with Discord (Demo Disabled)', + enabled: false }, { name: 'Twitter', provider: 'twitter', icon: Twitter, - color: 'bg-[#1DA1F2] hover:bg-[#1A91DA] text-white', - description: 'Continue with Twitter' + color: 'bg-gray-300 text-gray-500 cursor-not-allowed', + description: 'Continue with Twitter (Demo Disabled)', + enabled: false } ]; async function handleSubmit(e: Event) { e.preventDefault(); + + // Disable email/password authentication for demo + toaster.create({ + type: 'warning', + title: 'Demo Mode', + description: 'Email/password authentication is disabled in this demo. Please use GitHub login instead.' + }); + return; + + // Original code commented out for demo + /* loading = true; message = ''; @@ -110,9 +125,20 @@ } finally { loading = false; } + */ } async function handleOAuth(provider: string) { + // Only allow GitHub for demo + if (provider !== 'github') { + toaster.create({ + type: 'warning', + title: 'Demo Mode', + description: `${provider.charAt(0).toUpperCase() + provider.slice(1)} login is disabled in this demo. Only GitHub login is available.` + }); + return; + } + oauthLoading = provider; try { const { error } = await supabase.auth.signInWithOAuth({ @@ -149,6 +175,20 @@
+ +
+
+ +
+

Demo Mode

+

+ This is a demo deployment. Only GitHub login is enabled. + Email/password authentication and other OAuth providers are disabled for demonstration purposes. +

+
+
+
+
@@ -202,22 +242,21 @@
{/if} - +
-
+
@@ -229,21 +268,19 @@
@@ -291,9 +323,9 @@ {#if activeTab === 'login'}
- - Forgot your password? - + + Forgot your password? (Demo disabled) +
{/if} @@ -311,7 +343,7 @@ type="button" class="btn w-full flex items-center justify-center gap-3 {provider.color}" onclick={() => handleOAuth(provider.provider)} - disabled={loading || oauthLoading !== ''} + disabled={!provider.enabled || loading || oauthLoading !== ''} > {#if oauthLoading === provider.provider}
diff --git a/src/routes/auth/reset-password/+page.svelte b/src/routes/auth/reset-password/+page.svelte index 88d60fe..55e17fe 100644 --- a/src/routes/auth/reset-password/+page.svelte +++ b/src/routes/auth/reset-password/+page.svelte @@ -1,7 +1,7 @@ @@ -43,6 +55,19 @@
+ +
+
+ +
+

Demo Mode

+

+ Password reset is disabled in this demo. Only GitHub login is available. +

+
+
+
+
@@ -58,19 +83,18 @@
{#if !sent}
-
+

@@ -80,16 +104,11 @@

{:else} diff --git a/src/routes/auth/update-password/+page.svelte b/src/routes/auth/update-password/+page.svelte index d5d2647..b43f951 100644 --- a/src/routes/auth/update-password/+page.svelte +++ b/src/routes/auth/update-password/+page.svelte @@ -2,7 +2,7 @@ import { goto } from '$app/navigation'; import { toaster } from '$lib'; import { supabase } from '$lib/supabaseClient'; - import { Eye, EyeOff, KeyRound, Lock, Save } from '@lucide/svelte'; + import { Eye, EyeOff, KeyRound, Lock, Save, AlertTriangle } from '@lucide/svelte'; import type { Session } from '@supabase/supabase-js'; import { onMount } from 'svelte'; @@ -31,6 +31,16 @@ async function handleUpdatePassword(e: Event) { e.preventDefault(); + // Disable password update for demo + toaster.create({ + type: 'warning', + title: 'Demo Mode', + description: 'Password update is disabled in this demo. Please use GitHub login instead.' + }); + return; + + // Original code commented out for demo + /* if (password !== confirmPassword) { toaster.create({ type: 'error', @@ -64,7 +74,7 @@ description: 'Your password has been successfully updated.' }); - goto('/app/dashboard'); + goto('/dashboard'); } catch (error: any) { toaster.create({ type: 'error', @@ -74,6 +84,7 @@ } finally { loading = false; } + */ } @@ -84,6 +95,19 @@
+ +
+
+ +
+

Demo Mode

+

+ Password update is disabled in this demo. Only GitHub login is available. +

+
+
+
+
@@ -98,7 +122,7 @@
-
+