style: format entire codebase with prettier

This commit is contained in:
Rasmus Q
2026-03-15 21:02:57 +00:00
parent 47e02d81c3
commit f739288866
93 changed files with 5334 additions and 4976 deletions
+48 -48
View File
@@ -8,68 +8,68 @@ import { env } from '$env/dynamic/private';
import { sanitizeString, sanitizeUsername } from '$lib/server/validation';
export const load: PageServerLoad = async () => {
// Determine which OAuth providers are available
const oauthProviders = [];
// Determine which OAuth providers are available
const oauthProviders = [];
if (env.GOOGLE_CLIENT_ID && env.GOOGLE_CLIENT_SECRET) {
oauthProviders.push({ id: 'google', name: 'Google' });
}
if (env.GOOGLE_CLIENT_ID && env.GOOGLE_CLIENT_SECRET) {
oauthProviders.push({ id: 'google', name: 'Google' });
}
if (env.AUTHENTIK_CLIENT_ID && env.AUTHENTIK_CLIENT_SECRET && env.AUTHENTIK_ISSUER) {
oauthProviders.push({ id: 'authentik', name: 'Authentik' });
}
if (env.AUTHENTIK_CLIENT_ID && env.AUTHENTIK_CLIENT_SECRET && env.AUTHENTIK_ISSUER) {
oauthProviders.push({ id: 'authentik', name: 'Authentik' });
}
return {
oauthProviders
};
return {
oauthProviders
};
};
export const actions: Actions = {
default: async ({ request }) => {
const formData = await request.formData();
const name = formData.get('name') as string;
const username = formData.get('username') as string;
const password = formData.get('password') as string;
const confirmPassword = formData.get('confirmPassword') as string;
default: async ({ request }) => {
const formData = await request.formData();
const name = formData.get('name') as string;
const username = formData.get('username') as string;
const password = formData.get('password') as string;
const confirmPassword = formData.get('confirmPassword') as string;
let sanitizedUsername: string;
let sanitizedName: string | null;
let sanitizedUsername: string;
let sanitizedName: string | null;
try {
sanitizedName = sanitizeString(name, 100);
sanitizedUsername = sanitizeUsername(username);
} catch (error) {
return fail(400, { error: 'Invalid input', name, username });
}
try {
sanitizedName = sanitizeString(name, 100);
sanitizedUsername = sanitizeUsername(username);
} catch (error) {
return fail(400, { error: 'Invalid input', name, username });
}
if (!sanitizedName) {
return fail(400, { error: 'Name is required', name, username });
}
if (!sanitizedName) {
return fail(400, { error: 'Name is required', name, username });
}
if (!password || password.length < 8) {
return fail(400, { error: 'Password must be at least 8 characters', name, username });
}
if (!password || password.length < 8) {
return fail(400, { error: 'Password must be at least 8 characters', name, username });
}
if (password !== confirmPassword) {
return fail(400, { error: 'Passwords do not match', name, username });
}
if (password !== confirmPassword) {
return fail(400, { error: 'Passwords do not match', name, username });
}
const existingUser = await db.query.users.findFirst({
where: eq(users.username, sanitizedUsername)
});
const existingUser = await db.query.users.findFirst({
where: eq(users.username, sanitizedUsername)
});
if (existingUser) {
return fail(400, { error: 'Username already taken', name, username });
}
if (existingUser) {
return fail(400, { error: 'Username already taken', name, username });
}
const hashedPassword = await bcrypt.hash(password, 14);
const hashedPassword = await bcrypt.hash(password, 14);
await db.insert(users).values({
name: sanitizedName,
username: sanitizedUsername,
password: hashedPassword
});
await db.insert(users).values({
name: sanitizedName,
username: sanitizedUsername,
password: hashedPassword
});
throw redirect(303, '/signin?registered=true');
}
throw redirect(303, '/signin?registered=true');
}
};
+85 -71
View File
@@ -1,86 +1,100 @@
<script lang="ts">
import { Button } from '$lib/components/ui/button';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '$lib/components/ui/card';
import { Input } from '$lib/components/ui/input';
import { Label } from '$lib/components/ui/label';
import { ThemeToggle } from '$lib/components/ui/theme-toggle';
import { LanguageToggle } from '$lib/components/ui/language-toggle';
import type { ActionData, PageData } from './$types';
import { signIn } from '@auth/sveltekit/client';
import { languageStore } from '$lib/stores/language.svelte';
import { Button } from '$lib/components/ui/button';
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle
} from '$lib/components/ui/card';
import { Input } from '$lib/components/ui/input';
import { Label } from '$lib/components/ui/label';
import { ThemeToggle } from '$lib/components/ui/theme-toggle';
import { LanguageToggle } from '$lib/components/ui/language-toggle';
import type { ActionData, PageData } from './$types';
import { signIn } from '@auth/sveltekit/client';
import { languageStore } from '$lib/stores/language.svelte';
let { form, data }: { form: ActionData; data: PageData } = $props();
let { form, data }: { form: ActionData; data: PageData } = $props();
const t = $derived(languageStore.t);
const t = $derived(languageStore.t);
</script>
<div class="min-h-screen flex items-center justify-center p-4">
<div class="absolute top-4 right-4 flex items-center gap-1 sm:gap-2">
<LanguageToggle />
<ThemeToggle />
</div>
<Card class="w-full max-w-md">
<CardHeader>
<CardTitle class="text-2xl">{t.auth.createAccount}</CardTitle>
<CardDescription>{t.auth.signUpPrompt}</CardDescription>
</CardHeader>
<CardContent class="space-y-4">
{#if form?.error}
<div class="bg-red-50 border border-red-200 text-red-700 dark:bg-red-950 dark:border-red-800 dark:text-red-300 px-4 py-3 rounded">
{form.error}
</div>
{/if}
<div class="absolute top-4 right-4 flex items-center gap-1 sm:gap-2">
<LanguageToggle />
<ThemeToggle />
</div>
<Card class="w-full max-w-md">
<CardHeader>
<CardTitle class="text-2xl">{t.auth.createAccount}</CardTitle>
<CardDescription>{t.auth.signUpPrompt}</CardDescription>
</CardHeader>
<CardContent class="space-y-4">
{#if form?.error}
<div
class="bg-red-50 border border-red-200 text-red-700 dark:bg-red-950 dark:border-red-800 dark:text-red-300 px-4 py-3 rounded"
>
{form.error}
</div>
{/if}
<form method="POST" class="space-y-4">
<div class="space-y-2">
<Label for="name">{t.form.name}</Label>
<Input id="name" name="name" type="text" required value={form?.name || ''} />
</div>
<form method="POST" class="space-y-4">
<div class="space-y-2">
<Label for="name">{t.form.name}</Label>
<Input id="name" name="name" type="text" required value={form?.name || ''} />
</div>
<div class="space-y-2">
<Label for="username">{t.form.username}</Label>
<Input id="username" name="username" type="text" required value={form?.username || ''} />
</div>
<div class="space-y-2">
<Label for="username">{t.form.username}</Label>
<Input id="username" name="username" type="text" required value={form?.username || ''} />
</div>
<div class="space-y-2">
<Label for="password">{t.form.password}</Label>
<Input id="password" name="password" type="password" required minlength={8} />
</div>
<div class="space-y-2">
<Label for="password">{t.form.password}</Label>
<Input id="password" name="password" type="password" required minlength={8} />
</div>
<div class="space-y-2">
<Label for="confirmPassword">{t.form.confirmPassword}</Label>
<Input id="confirmPassword" name="confirmPassword" type="password" required minlength={8} />
</div>
<div class="space-y-2">
<Label for="confirmPassword">{t.form.confirmPassword}</Label>
<Input
id="confirmPassword"
name="confirmPassword"
type="password"
required
minlength={8}
/>
</div>
<Button type="submit" class="w-full">{t.auth.signUp}</Button>
</form>
<Button type="submit" class="w-full">{t.auth.signUp}</Button>
</form>
{#if data.oauthProviders.length > 0}
<div class="relative">
<div class="absolute inset-0 flex items-center">
<span class="w-full border-t"></span>
</div>
<div class="relative flex justify-center text-xs uppercase">
<span class="bg-card px-2 text-muted-foreground">{t.auth.continueWith}</span>
</div>
</div>
{#if data.oauthProviders.length > 0}
<div class="relative">
<div class="absolute inset-0 flex items-center">
<span class="w-full border-t"></span>
</div>
<div class="relative flex justify-center text-xs uppercase">
<span class="bg-card px-2 text-muted-foreground">{t.auth.continueWith}</span>
</div>
</div>
{#each data.oauthProviders as provider}
<Button
type="button"
variant="outline"
class="w-full"
onclick={() => signIn(provider.id, { callbackUrl: '/dashboard' })}
>
{t.auth.signUp} with {provider.name}
</Button>
{/each}
{/if}
{#each data.oauthProviders as provider}
<Button
type="button"
variant="outline"
class="w-full"
onclick={() => signIn(provider.id, { callbackUrl: '/dashboard' })}
>
{t.auth.signUp} with {provider.name}
</Button>
{/each}
{/if}
<div class="text-center text-sm text-muted-foreground">
{t.auth.alreadyHaveAccount}
<a href="/signin" class="text-primary hover:underline">{t.auth.signIn}</a>
</div>
</CardContent>
</Card>
<div class="text-center text-sm text-muted-foreground">
{t.auth.alreadyHaveAccount}
<a href="/signin" class="text-primary hover:underline">{t.auth.signIn}</a>
</div>
</CardContent>
</Card>
</div>