adding logs

This commit is contained in:
Luke Hagar
2025-05-28 13:37:54 -05:00
parent cff5fccdee
commit c8a032a16e
4 changed files with 148 additions and 80 deletions

View File

@@ -67,10 +67,12 @@ const authGuard: Handle = async ({ event, resolve }) => {
event.locals.session = session; event.locals.session = session;
event.locals.user = user; event.locals.user = user;
console.log(event.locals);
// Protect routes that require authentication // Protect routes that require authentication
if (event.url.pathname.startsWith('/app')) { if (event.url.pathname.startsWith('/app')) {
if (!session) { if (!session) {
throw redirect(303, '/auth/login'); throw redirect(303, '/auth');
} }
} }

View File

@@ -2,7 +2,7 @@
import { supabase } from '$lib/supabaseClient'; import { supabase } from '$lib/supabaseClient';
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
import { toaster } from '$lib'; 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'; import { onMount } from 'svelte';
let activeTab = $state('login'); // 'login' or 'signup' let activeTab = $state('login'); // 'login' or 'signup'
@@ -26,40 +26,55 @@
let oauthLoading = $state(''); let oauthLoading = $state('');
let message = $state(''); let message = $state('');
// OAuth providers configuration // OAuth providers configuration - only GitHub enabled for demo
const oauthProviders = [ const oauthProviders = [
{ {
name: 'GitHub', name: 'GitHub',
provider: 'github', provider: 'github',
icon: Github, icon: Github,
color: 'bg-[#333] hover:bg-[#555] text-white', color: 'bg-[#333] hover:bg-[#555] text-white',
description: 'Continue with GitHub' description: 'Continue with GitHub',
enabled: true
}, },
{ {
name: 'Google', name: 'Google',
provider: 'google', provider: 'google',
icon: Chrome, icon: Chrome,
color: 'bg-white hover:bg-gray-50 text-gray-900 border border-gray-300', color: 'bg-gray-300 text-gray-500 cursor-not-allowed',
description: 'Continue with Google' description: 'Continue with Google (Demo Disabled)',
enabled: false
}, },
{ {
name: 'Discord', name: 'Discord',
provider: 'discord', provider: 'discord',
icon: MessageCircle, icon: MessageCircle,
color: 'bg-[#5865F2] hover:bg-[#4752C4] text-white', color: 'bg-gray-300 text-gray-500 cursor-not-allowed',
description: 'Continue with Discord' description: 'Continue with Discord (Demo Disabled)',
enabled: false
}, },
{ {
name: 'Twitter', name: 'Twitter',
provider: 'twitter', provider: 'twitter',
icon: Twitter, icon: Twitter,
color: 'bg-[#1DA1F2] hover:bg-[#1A91DA] text-white', color: 'bg-gray-300 text-gray-500 cursor-not-allowed',
description: 'Continue with Twitter' description: 'Continue with Twitter (Demo Disabled)',
enabled: false
} }
]; ];
async function handleSubmit(e: Event) { async function handleSubmit(e: Event) {
e.preventDefault(); 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; loading = true;
message = ''; message = '';
@@ -110,9 +125,20 @@
} finally { } finally {
loading = false; loading = false;
} }
*/
} }
async function handleOAuth(provider: string) { 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; oauthLoading = provider;
try { try {
const { error } = await supabase.auth.signInWithOAuth({ const { error } = await supabase.auth.signInWithOAuth({
@@ -149,6 +175,20 @@
<div class="container mx-auto py-20"> <div class="container mx-auto py-20">
<div class="max-w-md mx-auto space-y-8"> <div class="max-w-md mx-auto space-y-8">
<!-- Demo Notice -->
<div class="card preset-outlined-warning-500 p-4">
<div class="flex items-start gap-3">
<AlertTriangle class="size-5 text-warning-500 flex-shrink-0 mt-0.5" />
<div class="space-y-2">
<h3 class="font-semibold text-warning-700 dark:text-warning-300">Demo Mode</h3>
<p class="text-sm text-warning-600 dark:text-warning-400">
This is a demo deployment. Only <strong>GitHub login</strong> is enabled.
Email/password authentication and other OAuth providers are disabled for demonstration purposes.
</p>
</div>
</div>
</div>
<!-- Header --> <!-- Header -->
<header class="text-center space-y-4"> <header class="text-center space-y-4">
<div class="flex items-center justify-center gap-2 mb-4"> <div class="flex items-center justify-center gap-2 mb-4">
@@ -202,22 +242,21 @@
</div> </div>
{/if} {/if}
<!-- Email/Password Form --> <!-- Email/Password Form (Disabled for demo) -->
<form onsubmit={handleSubmit} class="space-y-6"> <form onsubmit={handleSubmit} class="space-y-6">
<div class="space-y-4"> <div class="space-y-4 opacity-50">
<div class="space-y-2"> <div class="space-y-2">
<label class="label font-medium" for="email"> <label class="label font-medium" for="email">
<Mail class="size-4 inline mr-2" /> <Mail class="size-4 inline mr-2" />
Email Address Email Address
</label> </label>
<input <input
class="input preset-outlined-primary-500" class="input preset-outlined-surface-200-800"
type="email" type="email"
id="email" id="email"
bind:value={formData.email} bind:value={formData.email}
placeholder="Enter your email" placeholder="Enter your email (disabled in demo)"
required disabled={true}
disabled={loading || oauthLoading !== ''}
autocomplete="email" autocomplete="email"
/> />
</div> </div>
@@ -229,21 +268,19 @@
</label> </label>
<div class="relative"> <div class="relative">
<input <input
class="input preset-outlined-primary-500 pr-10" class="input preset-outlined-surface-200-800 pr-10"
type={showPassword ? 'text' : 'password'} type={showPassword ? 'text' : 'password'}
id="password" id="password"
bind:value={formData.password} bind:value={formData.password}
placeholder={activeTab === 'login' ? 'Enter your password' : 'Create a strong password'} placeholder={activeTab === 'login' ? 'Enter your password (disabled)' : 'Create a strong password (disabled)'}
required disabled={true}
disabled={loading || oauthLoading !== ''}
minlength={activeTab === 'signup' ? 6 : undefined} minlength={activeTab === 'signup' ? 6 : undefined}
autocomplete={activeTab === 'login' ? 'current-password' : 'new-password'} autocomplete={activeTab === 'login' ? 'current-password' : 'new-password'}
/> />
<button <button
type="button" type="button"
class="absolute right-3 top-1/2 -translate-y-1/2 text-surface-500 hover:text-surface-700 dark:hover:text-surface-300" class="absolute right-3 top-1/2 -translate-y-1/2 text-surface-500"
onclick={() => showPassword = !showPassword} disabled={true}
disabled={loading || oauthLoading !== ''}
> >
{#if showPassword} {#if showPassword}
<EyeOff class="size-4" /> <EyeOff class="size-4" />
@@ -260,20 +297,15 @@
<button <button
type="submit" type="submit"
class="btn preset-filled-primary-500 w-full flex items-center justify-center gap-2" class="btn preset-outlined-surface-200-800 w-full flex items-center justify-center gap-2 opacity-50 cursor-not-allowed"
disabled={loading || oauthLoading !== ''} disabled={true}
> >
{#if loading} {#if activeTab === 'login'}
<div class="animate-spin rounded-full h-4 w-4 border-b-2 border-white"></div> <LogIn class="size-4" />
{activeTab === 'login' ? 'Signing you in...' : 'Creating your account...'} Sign In (Demo Disabled)
{:else} {:else}
{#if activeTab === 'login'} <UserPlus class="size-4" />
<LogIn class="size-4" /> Create Account (Demo Disabled)
Sign In
{:else}
<UserPlus class="size-4" />
Create Account
{/if}
{/if} {/if}
</button> </button>
</form> </form>
@@ -291,9 +323,9 @@
<!-- Forgot Password for Login --> <!-- Forgot Password for Login -->
{#if activeTab === 'login'} {#if activeTab === 'login'}
<div class="text-center"> <div class="text-center">
<a href="/auth/reset-password" class="text-sm text-primary-500 hover:text-primary-600 transition-colors"> <span class="text-sm text-surface-500 opacity-50">
Forgot your password? Forgot your password? (Demo disabled)
</a> </span>
</div> </div>
{/if} {/if}
@@ -311,7 +343,7 @@
type="button" type="button"
class="btn w-full flex items-center justify-center gap-3 {provider.color}" class="btn w-full flex items-center justify-center gap-3 {provider.color}"
onclick={() => handleOAuth(provider.provider)} onclick={() => handleOAuth(provider.provider)}
disabled={loading || oauthLoading !== ''} disabled={!provider.enabled || loading || oauthLoading !== ''}
> >
{#if oauthLoading === provider.provider} {#if oauthLoading === provider.provider}
<div class="animate-spin rounded-full h-4 w-4 border-b-2 border-current"></div> <div class="animate-spin rounded-full h-4 w-4 border-b-2 border-current"></div>

View File

@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { supabase } from '$lib/supabaseClient'; import { supabase } from '$lib/supabaseClient';
import { toaster } from '$lib'; import { toaster } from '$lib';
import { Mail, Send, ArrowLeft, KeyRound } from '@lucide/svelte'; import { Mail, Send, ArrowLeft, KeyRound, AlertTriangle } from '@lucide/svelte';
let email = $state(''); let email = $state('');
let loading = $state(false); let loading = $state(false);
@@ -9,6 +9,17 @@
async function handleReset(e: Event) { async function handleReset(e: Event) {
e.preventDefault(); e.preventDefault();
// Disable password reset for demo
toaster.create({
type: 'warning',
title: 'Demo Mode',
description: 'Password reset is disabled in this demo. Please use GitHub login instead.'
});
return;
// Original code commented out for demo
/*
loading = true; loading = true;
try { try {
@@ -33,6 +44,7 @@
} finally { } finally {
loading = false; loading = false;
} }
*/
} }
</script> </script>
@@ -43,6 +55,19 @@
<div class="container mx-auto py-20"> <div class="container mx-auto py-20">
<div class="max-w-md mx-auto space-y-8"> <div class="max-w-md mx-auto space-y-8">
<!-- Demo Notice -->
<div class="card preset-outlined-warning-500 p-4">
<div class="flex items-start gap-3">
<AlertTriangle class="size-5 text-warning-500 flex-shrink-0 mt-0.5" />
<div class="space-y-2">
<h3 class="font-semibold text-warning-700 dark:text-warning-300">Demo Mode</h3>
<p class="text-sm text-warning-600 dark:text-warning-400">
Password reset is disabled in this demo. Only <strong>GitHub login</strong> is available.
</p>
</div>
</div>
</div>
<!-- Header --> <!-- Header -->
<header class="text-center space-y-4"> <header class="text-center space-y-4">
<div class="flex items-center justify-center gap-2 mb-4"> <div class="flex items-center justify-center gap-2 mb-4">
@@ -58,19 +83,18 @@
<div class="card preset-outlined-primary-500 p-8 space-y-6"> <div class="card preset-outlined-primary-500 p-8 space-y-6">
{#if !sent} {#if !sent}
<form onsubmit={handleReset} class="space-y-6"> <form onsubmit={handleReset} class="space-y-6">
<div class="space-y-2"> <div class="space-y-2 opacity-50">
<label class="label font-medium" for="email"> <label class="label font-medium" for="email">
<Mail class="size-4 inline mr-2" /> <Mail class="size-4 inline mr-2" />
Email Address Email Address
</label> </label>
<input <input
class="input preset-outlined-secondary-500" class="input preset-outlined-surface-200-800"
type="email" type="email"
id="email" id="email"
bind:value={email} bind:value={email}
placeholder="Enter your email address" placeholder="Enter your email address (disabled in demo)"
required disabled={true}
disabled={loading}
autocomplete="email" autocomplete="email"
/> />
<p class="text-xs opacity-75"> <p class="text-xs opacity-75">
@@ -80,16 +104,11 @@
<button <button
type="submit" type="submit"
class="btn preset-filled-primary-500 w-full flex items-center justify-center gap-2" class="btn preset-outlined-surface-200-800 w-full flex items-center justify-center gap-2 opacity-50 cursor-not-allowed"
disabled={loading} disabled={true}
> >
{#if loading} <Send class="size-4" />
<div class="animate-spin rounded-full h-4 w-4 border-b-2 border-white"></div> Send Reset Email (Demo Disabled)
Sending reset email...
{:else}
<Send class="size-4" />
Send Reset Email
{/if}
</button> </button>
</form> </form>
{:else} {:else}

View File

@@ -2,7 +2,7 @@
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
import { toaster } from '$lib'; import { toaster } from '$lib';
import { supabase } from '$lib/supabaseClient'; 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 type { Session } from '@supabase/supabase-js';
import { onMount } from 'svelte'; import { onMount } from 'svelte';
@@ -31,6 +31,16 @@
async function handleUpdatePassword(e: Event) { async function handleUpdatePassword(e: Event) {
e.preventDefault(); 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) { if (password !== confirmPassword) {
toaster.create({ toaster.create({
type: 'error', type: 'error',
@@ -64,7 +74,7 @@
description: 'Your password has been successfully updated.' description: 'Your password has been successfully updated.'
}); });
goto('/app/dashboard'); goto('/dashboard');
} catch (error: any) { } catch (error: any) {
toaster.create({ toaster.create({
type: 'error', type: 'error',
@@ -74,6 +84,7 @@
} finally { } finally {
loading = false; loading = false;
} }
*/
} }
</script> </script>
@@ -84,6 +95,19 @@
<div class="container mx-auto py-20"> <div class="container mx-auto py-20">
<div class="max-w-md mx-auto space-y-8"> <div class="max-w-md mx-auto space-y-8">
<!-- Demo Notice -->
<div class="card preset-outlined-warning-500 p-4">
<div class="flex items-start gap-3">
<AlertTriangle class="size-5 text-warning-500 flex-shrink-0 mt-0.5" />
<div class="space-y-2">
<h3 class="font-semibold text-warning-700 dark:text-warning-300">Demo Mode</h3>
<p class="text-sm text-warning-600 dark:text-warning-400">
Password update is disabled in this demo. Only <strong>GitHub login</strong> is available.
</p>
</div>
</div>
</div>
<!-- Header --> <!-- Header -->
<header class="text-center space-y-4"> <header class="text-center space-y-4">
<div class="flex items-center justify-center gap-2 mb-4"> <div class="flex items-center justify-center gap-2 mb-4">
@@ -98,7 +122,7 @@
<!-- Update Form Card --> <!-- Update Form Card -->
<div class="card preset-outlined-surface-200-800 p-8 space-y-6"> <div class="card preset-outlined-surface-200-800 p-8 space-y-6">
<form onsubmit={handleUpdatePassword} class="space-y-6"> <form onsubmit={handleUpdatePassword} class="space-y-6">
<div class="space-y-4"> <div class="space-y-4 opacity-50">
<div class="space-y-2"> <div class="space-y-2">
<label class="label font-medium" for="password"> <label class="label font-medium" for="password">
<Lock class="size-4 inline mr-2" /> <Lock class="size-4 inline mr-2" />
@@ -110,17 +134,15 @@
type={showPassword ? 'text' : 'password'} type={showPassword ? 'text' : 'password'}
id="password" id="password"
bind:value={password} bind:value={password}
placeholder="Create a strong password" placeholder="Create a strong password (disabled in demo)"
required disabled={true}
disabled={loading}
minlength="6" minlength="6"
autocomplete="new-password" autocomplete="new-password"
/> />
<button <button
type="button" type="button"
class="absolute right-3 top-1/2 -translate-y-1/2 text-surface-500 hover:text-surface-700 dark:hover:text-surface-300" class="absolute right-3 top-1/2 -translate-y-1/2 text-surface-500"
onclick={() => showPassword = !showPassword} disabled={true}
disabled={loading}
> >
{#if showPassword} {#if showPassword}
<EyeOff class="size-4" /> <EyeOff class="size-4" />
@@ -143,16 +165,14 @@
type={showConfirmPassword ? 'text' : 'password'} type={showConfirmPassword ? 'text' : 'password'}
id="confirmPassword" id="confirmPassword"
bind:value={confirmPassword} bind:value={confirmPassword}
placeholder="Confirm your password" placeholder="Confirm your password (disabled in demo)"
required disabled={true}
disabled={loading}
autocomplete="new-password" autocomplete="new-password"
/> />
<button <button
type="button" type="button"
class="absolute right-3 top-1/2 -translate-y-1/2 text-surface-500 hover:text-surface-700 dark:hover:text-surface-300" class="absolute right-3 top-1/2 -translate-y-1/2 text-surface-500"
onclick={() => showConfirmPassword = !showConfirmPassword} disabled={true}
disabled={loading}
> >
{#if showConfirmPassword} {#if showConfirmPassword}
<EyeOff class="size-4" /> <EyeOff class="size-4" />
@@ -166,7 +186,7 @@
<!-- Password Strength Indicator --> <!-- Password Strength Indicator -->
{#if password.length > 0} {#if password.length > 0}
<div class="space-y-2"> <div class="space-y-2 opacity-50">
<p class="text-sm font-medium">Password Strength:</p> <p class="text-sm font-medium">Password Strength:</p>
<div class="flex gap-1"> <div class="flex gap-1">
<div class="h-2 flex-1 rounded {password.length >= 6 ? 'bg-success-500' : 'bg-surface-300'}"></div> <div class="h-2 flex-1 rounded {password.length >= 6 ? 'bg-success-500' : 'bg-surface-300'}"></div>
@@ -189,7 +209,7 @@
<!-- Password Match Indicator --> <!-- Password Match Indicator -->
{#if confirmPassword.length > 0} {#if confirmPassword.length > 0}
<div class="flex items-center gap-2 text-sm"> <div class="flex items-center gap-2 text-sm opacity-50">
{#if password === confirmPassword} {#if password === confirmPassword}
<div class="w-2 h-2 bg-success-500 rounded-full"></div> <div class="w-2 h-2 bg-success-500 rounded-full"></div>
<span class="text-success-600 dark:text-success-400">Passwords match</span> <span class="text-success-600 dark:text-success-400">Passwords match</span>
@@ -202,16 +222,11 @@
<button <button
type="submit" type="submit"
class="btn preset-filled-primary-500 w-full flex items-center justify-center gap-2" class="btn preset-outlined-surface-200-800 w-full flex items-center justify-center gap-2 opacity-50 cursor-not-allowed"
disabled={loading || password !== confirmPassword || password.length < 6} disabled={true}
> >
{#if loading} <Save class="size-4" />
<div class="animate-spin rounded-full h-4 w-4 border-b-2 border-white"></div> Update Password (Demo Disabled)
Updating password...
{:else}
<Save class="size-4" />
Update Password
{/if}
</button> </button>
</form> </form>
</div> </div>