Files
LivingDexTracker/src/lib/components/SignUp.svelte
T
Josh Creek 3a2c18bbeb fix: repair defects surfaced by gating CI on lint and typecheck
`npm run check` reported 15 errors and `npm run lint` 20, all pre-existing, so
neither gate could pass. Fixing them turned up three real bugs:

- SignOut destructured `{ error }` off `.then(() => {})`, which resolves to
  undefined, so every sign-out threw a TypeError - after the signed-out event had
  already been emitted. Sign-out also left the user on the protected page they
  were on, still showing its content; it now returns them to the home page and
  re-runs the server loads.

- SignUp passed `redirectTo`, which is not a signUp option and was silently
  ignored, so the confirmation link has always used Supabase's configured site
  URL. Documented rather than changed, since pointing it elsewhere needs an
  absolute allow-listed URL.

- The Pokédex page tracked totalRecordsCreated but never passed it to the box
  view, so the "Processed N entries so far" progress message never rendered.

The rest is typing and dead code: cookie callback parameters in hooks.server.ts
and +layout.ts, the untyped supabase props, a query-builder type that made
PostgREST rows untyped downstream, an unused session destructure, and
`while (true)` paging loops rewritten as `for (;;)`.
2026-09-13 17:38:42 +01:00

76 lines
1.8 KiB
Svelte

<script lang="ts">
import type { SupabaseClient } from '@supabase/supabase-js';
import { createEventDispatcher } from 'svelte';
const dispatch = createEventDispatcher();
let email = '';
let password = '';
// Access the supabase client from the layout data
export let supabase: SupabaseClient;
async function signUpNewUser() {
try {
// `redirectTo` is not a signUp option - it was silently ignored, so the confirmation
// link has always used Supabase's configured site URL. Sending the user to /welcome
// would need `emailRedirectTo` with an absolute, allow-listed URL.
const { data, error } = await supabase.auth.signUp({
email: email,
password: password
});
if (error) {
console.error('Sign up error:', error);
alert(`Sign up failed: ${error.message}`);
return;
}
if (data) {
// Emit signedUp event to notify parent component
dispatch('signedUp', {});
}
} catch (err) {
console.error('Sign up error:', err);
alert('Sign up failed');
}
}
</script>
<form class="card-body">
<div class="form-control">
<label class="label" for="signup-email">
<span class="label-text">Email</span>
</label>
<input
id="signup-email"
type="email"
placeholder="email"
class="input input-bordered"
required
bind:value={email}
/>
</div>
<div class="form-control">
<label class="label" for="signup-password">
<span class="label-text">Password</span>
</label>
<input
id="signup-password"
type="password"
placeholder="password"
class="input input-bordered"
required
bind:value={password}
/>
</div>
<div class="form-control mt-6">
<button class="btn btn-primary" on:click={signUpNewUser}>Sign Up</button>
</div>
</form>
<style>
.card-body {
padding: 0.5rem;
}
</style>