fix: utils & register / confirmation issue

This commit is contained in:
glazk0 2024-02-19 22:06:12 +01:00
parent 0eabfa812f
commit f1889e0eab
No known key found for this signature in database
GPG key ID: E45BF177782B9FEB
46 changed files with 206 additions and 158 deletions

View file

@ -80,10 +80,13 @@
@layer base {
* {
box-sizing: border-box;
scroll-behavior: smooth;
@apply border-border text-white;
}
body {
@apply text-foreground;
@apply text-foreground bg-gradient-to-b from-primary-800 to-primary-900;
}
}
@ -91,6 +94,7 @@
.console {
@apply relative top-0.5 inline-block;
}
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,

4
src/app.d.ts vendored
View file

@ -7,10 +7,10 @@ declare global {
namespace App {
// interface Error {}
interface Locals {
user?: User;
user: User | null;
}
interface PageData {
user?: User;
user: User | null;
}
// interface Platform {}
}

View file

@ -1,28 +1,6 @@
<!DOCTYPE html>
<html lang="fr" class="scroll-smooth bg-gradient-to-b from-primary-800 to-primary-900">
<html lang="fr">
<head>
<meta charset="utf-8" />
<link rel="icon" type="image/x-icon" href="%sveltekit.assets%/favicon.ico" />
<link
rel="apple-touch-icon"
sizes="180x180"
href="%sveltekit.assets%/assets/icons/apple-touch-icon.png"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="%sveltekit.assets%/assets/icons/favicon-32x32.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="%sveltekit.assets%/assets/icons/favicon-16x16.png"
/>
<meta name="viewport" content="width=device-width" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover" class="relative min-h-screen">

View file

@ -4,24 +4,27 @@ import { API_URL } from '$env/static/private';
import type { User } from '$lib/types';
export const handle = (async ({ event, resolve }) => {
export const handle: Handle = async ({ event, resolve }) => {
const session = event.cookies.get('session');
if (session) {
const res = await fetch(`${API_URL}/player/`, {
headers: {
Authorization: `Bearer ${session}`
}
});
if (res.ok) {
const user = (await res.json()) as User;
event.locals.user = user;
} else {
event.locals.user = undefined;
event.cookies.delete('session');
}
if (!session) {
event.locals.user = null;
return resolve(event);
}
return await resolve(event);
}) satisfies Handle;
const res = await fetch(`${API_URL}/player/`, {
headers: {
Authorization: `Bearer ${session}`
}
});
if (res.ok) {
const user = (await res.json()) as User;
event.locals.user = user;
} else {
event.locals.user = null;
event.cookies.delete('session', { path: '/' });
}
return resolve(event);
};

View file

@ -1,5 +1,5 @@
<script lang="ts">
import { cn } from '$lib/Utils';
import { cn } from '$lib/utils';
export let name: string;
export let src: string;

View file

@ -1,11 +1,11 @@
<script lang="ts">
import { cn } from '$lib/Utils';
import type { Chapter } from '$lib/types';
import { Trophy } from 'lucide-svelte';
import ChevronRight from './Icons/ChevronRight.svelte';
import Button from './ui/Button.svelte';
import type { Chapter } from '$lib/types';
import { cn } from '$lib/utils';
import ChevronRight from './Icons/ChevronRight.svelte';
export let chapter: Chapter;
</script>

View file

@ -1,5 +1,5 @@
<script lang="ts">
import { cn } from '$lib';
import { cn } from '$lib/utils';
let className: string | undefined | null = undefined;

View file

@ -1,5 +1,5 @@
<script lang="ts">
import { cn } from '$lib';
import { cn } from '$lib/utils';
let className: string | undefined | null = undefined;

View file

@ -1,5 +1,5 @@
<script lang="ts">
import { cn } from '$lib';
import { cn } from '$lib/utils';
let className: string | undefined | null = undefined;

View file

@ -1,5 +1,5 @@
<script lang="ts">
import { cn } from '$lib';
import { cn } from '$lib/utils';
let className: string | undefined | null = undefined;

View file

@ -1,5 +1,5 @@
<script lang="ts">
import { cn } from '$lib';
import { cn } from '$lib/utils';
let className: string | undefined | null = undefined;

View file

@ -1,5 +1,5 @@
<script lang="ts">
import { cn } from '$lib';
import { cn } from '$lib/utils';
let className: string | undefined | null = undefined;
@ -16,4 +16,4 @@
><path
d="M524.531,69.836a1.5,1.5,0,0,0-.764-.7A485.065,485.065,0,0,0,404.081,32.03a1.816,1.816,0,0,0-1.923.91,337.461,337.461,0,0,0-14.9,30.6,447.848,447.848,0,0,0-134.426,0,309.541,309.541,0,0,0-15.135-30.6,1.89,1.89,0,0,0-1.924-.91A483.689,483.689,0,0,0,116.085,69.137a1.712,1.712,0,0,0-.788.676C39.068,183.651,18.186,294.69,28.43,404.354a2.016,2.016,0,0,0,.765,1.375A487.666,487.666,0,0,0,176.02,479.918a1.9,1.9,0,0,0,2.063-.676A348.2,348.2,0,0,0,208.12,430.4a1.86,1.86,0,0,0-1.019-2.588,321.173,321.173,0,0,1-45.868-21.853,1.885,1.885,0,0,1-.185-3.126c3.082-2.309,6.166-4.711,9.109-7.137a1.819,1.819,0,0,1,1.9-.256c96.229,43.917,200.41,43.917,295.5,0a1.812,1.812,0,0,1,1.924.233c2.944,2.426,6.027,4.851,9.132,7.16a1.884,1.884,0,0,1-.162,3.126,301.407,301.407,0,0,1-45.89,21.83,1.875,1.875,0,0,0-1,2.611,391.055,391.055,0,0,0,30.014,48.815,1.864,1.864,0,0,0,2.063.7A486.048,486.048,0,0,0,610.7,405.729a1.882,1.882,0,0,0,.765-1.352C623.729,277.594,590.933,167.465,524.531,69.836ZM222.491,337.58c-28.972,0-52.844-26.587-52.844-59.239S193.056,219.1,222.491,219.1c29.665,0,53.306,26.82,52.843,59.239C275.334,310.993,251.924,337.58,222.491,337.58Zm195.38,0c-28.971,0-52.843-26.587-52.843-59.239S388.437,219.1,417.871,219.1c29.667,0,53.307,26.82,52.844,59.239C470.715,310.993,447.538,337.58,417.871,337.58Z"
/></svg
>
>

View file

@ -1,5 +1,5 @@
<script lang="ts">
import { cn } from '$lib';
import { cn } from '$lib/utils';
let className: string | undefined | null = undefined;

View file

@ -1,5 +1,5 @@
<script lang="ts">
import { cn } from '$lib';
import { cn } from '$lib/utils';
let className: string | undefined | null = undefined;

View file

@ -1,5 +1,5 @@
<script lang="ts">
import { cn } from '$lib';
import { cn } from '$lib/utils';
let className: string | undefined | null = undefined;

View file

@ -1,5 +1,5 @@
<script lang="ts">
import { cn } from '$lib';
import { cn } from '$lib/utils';
let className: string | undefined | null = undefined;

View file

@ -1,5 +1,5 @@
<script lang="ts">
import { cn } from '$lib';
import { cn } from '$lib/utils';
let className: string | undefined | null = undefined;

View file

@ -1,5 +1,5 @@
<script lang="ts">
import { cn } from '$lib';
import { cn } from '$lib/utils';
let className: string | undefined | null = undefined;

View file

@ -0,0 +1,49 @@
<script lang="ts">
import { page } from '$app/stores';
import { siteConfig } from '$lib/config/site';
</script>
<svelte:head>
{#key $page.url.pathname}
<title>{siteConfig.title}</title>
<meta name="title" content={siteConfig.title} />
<meta name="description" content={siteConfig.description} />
<meta name="keywords" content={siteConfig.keywords.join(',')} />
<meta name="author" content={siteConfig.author} />
<meta name="theme-color" content={siteConfig.themeColor} />
<meta name="robots" content="index,follow" />
<meta itemprop="name" content={siteConfig.title} />
<meta itemprop="description" content={siteConfig.description} />
<meta itemprop="image" content={siteConfig.imageUrl} />
<meta property="og:site_name" content={siteConfig.name} />
<meta property="og:title" content={siteConfig.title} />
<meta property="og:description" content={siteConfig.description} />
<meta property="og:type" content="website" />
<meta property="og:url" content={siteConfig.url + $page.url.pathname} />
<meta property="og:image" content={siteConfig.imageUrl} />
<meta property="og:image:alt" content={siteConfig.title} />
<meta property="og:locale" content={siteConfig.locale} />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content={siteConfig.url} />
<meta name="twitter:title" content={siteConfig.title} />
<meta name="twitter:description" content={siteConfig.description} />
<meta name="twitter:image" content={siteConfig.imageUrl} />
<meta name="twitter:image:alt" content={siteConfig.title} />
<meta name="twitter:creator" content={siteConfig.twitter.creator} />
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<meta name="viewport" content="width=device-width" />
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
<link rel="apple-touch-icon" sizes="180x180" href="/assets/icons/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/assets/icons/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/assets/icons/favicon-16x16.png" />
{/key}
</svelte:head>

View file

@ -1,6 +1,6 @@
<script lang="ts">
import { page } from '$app/stores';
import { cn } from '$lib/Utils';
import { cn } from '$lib/utils';
import type { Puzzle } from '$lib/types';
import ChevronRight from './Icons/ChevronRight.svelte';

View file

@ -1,7 +1,7 @@
<script lang="ts">
import { page } from '$app/stores';
import { cn } from '$lib/Utils';
import { cn } from '$lib/utils';
import Badge from '$lib/components/Icons/Badge.svelte';
import Code from '$lib/components/Icons/Code.svelte';

View file

@ -2,9 +2,7 @@
import type { HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements';
import { type VariantProps, cva } from 'class-variance-authority';
import { cn } from '$lib';
// TODO: Remove this
import { cn } from '$lib/utils';
export const buttonVariants = cva(
'inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',

View file

@ -1,7 +1,7 @@
<script lang="ts">
import type { HTMLInputAttributes } from 'svelte/elements';
import { cn } from '$lib';
import { cn } from '$lib/utils';
type FormInputEvent<T extends Event = Event> = T & {
currentTarget: EventTarget & HTMLInputElement;

16
src/lib/config/site.ts Normal file
View file

@ -0,0 +1,16 @@
export const siteConfig = {
name: 'Peer-at Code',
url: 'https://app.peerat.dev',
title: 'Peer-at Code',
description: 'Apprendre la programmation et la cybersécurité en s\'amusant.',
imageUrl: 'https://my-site.com/images/og-image.jpg',
keywords: ['peerat', 'code', 'cybersecurite', 'programmation', 'apprendre en s\'amusant'],
author: 'peerat',
locale: 'fr',
twitter: {
creator: '@peerat'
},
themeColor: '#110F15'
};
export type SiteConfig = typeof siteConfig;

View file

@ -1 +0,0 @@
export * from './Utils';

View file

@ -1 +1 @@
export * from './Database';
export * from './database';

View file

@ -1,6 +1,6 @@
import { clsx, type ClassValue } from 'clsx';
import { twMerge } from 'tailwind-merge';
export function cn(...inputs: ClassValue[]) {
export const cn = (...inputs: ClassValue[]) => {
return twMerge(clsx(inputs));
}

View file

@ -1,43 +1,14 @@
<script lang="ts">
import '../app.css';
import { page } from '$app/stores';
import Metadata from '$lib/components/Metadata.svelte';
import Toaster from '$lib/components/Toaster.svelte';
$: origin = $page.url.origin;
$: domain = $page.url.hostname;
</script>
<Metadata />
<svelte:head>
<title>Peer-at Code</title>
<meta name="title" content="Peer-at Code" />
<meta name="description" content="Apprendre la programmation et la cybersécurité en s'amusant." />
<meta name="theme-color" content="#110F15" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="French" />
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website" />
<meta property="og:url" content={origin} />
<meta property="og:title" content="Peer-at Code" />
<meta
property="og:description"
content="Apprendre la programmation et la cybersécurité en s'amusant."
/>
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:url" content={origin} />
<meta property="twitter:title" content="Peer-at Code" />
<meta
property="twitter:description"
content="Apprendre la programmation et la cybersécurité en s'amusant."
/>
<script defer data-domain={domain} src="https://plosibl.peerat.dev/js/script.js"></script>
<script defer data-domain="app.peerat.dev" src="https://plosibl.peerat.dev/js/script.js"></script>
</svelte:head>
<Toaster />

View file

@ -2,6 +2,6 @@ import { redirect } from '@sveltejs/kit';
import type { PageServerLoad } from './$types';
export const load = (async ({ locals: { user } }) => {
if (user) throw redirect(303, '/dashboard');
throw redirect(303, '/sign-in');
if (user) redirect(303, '/dashboard');
redirect(303, '/sign-in');
}) satisfies PageServerLoad;

View file

@ -1,2 +0,0 @@
<script lang="ts">
</script>

View file

@ -2,5 +2,5 @@ import { redirect, type ServerLoad } from '@sveltejs/kit';
export const load: ServerLoad = async ({ locals: { user }, parent }) => {
await parent();
if (!user) throw redirect(303, '/sign-in');
if (!user) redirect(303, '/sign-in');
};

View file

@ -17,13 +17,13 @@ export const load = (async ({ parent, fetch, cookies, params: { chapterId } }) =
});
if (!res.ok) {
throw redirect(302, '/dashboard/chapters');
redirect(302, '/dashboard/chapters');
}
const chapter = (await res.json()) as Chapter;
if (!chapter || !chapter.show) {
throw redirect(302, '/dashboard/chapters');
redirect(302, '/dashboard/chapters');
}
return {

View file

@ -4,5 +4,5 @@ import type { PageServerLoad } from './$types';
export const load = (async ({ parent, params: { chapterId } }) => {
await parent();
throw redirect(303, chapterId ? `/dashboard/chapters/${chapterId}` : `/dashboard/chapters`);
redirect(303, chapterId ? `/dashboard/chapters/${chapterId}` : `/dashboard/chapters`);
}) satisfies PageServerLoad;

View file

@ -11,7 +11,7 @@ export const load = (async ({ parent, fetch, cookies, params: { chapterId, puzzl
const session = cookies.get('session');
if (isNaN(parseInt(puzzleId))) {
throw redirect(303, `/dashboard/chapters/${chapterId}`);
redirect(303, `/dashboard/chapters/${chapterId}`);
}
let res = await fetch(`${API_URL}/chapter/${chapterId}`, {
@ -21,20 +21,20 @@ export const load = (async ({ parent, fetch, cookies, params: { chapterId, puzzl
});
if (!res.ok) {
throw redirect(303, `/dashboard/chapters`);
redirect(303, `/dashboard/chapters`);
}
const chapter = (await res.json()) as Chapter;
if (!chapter || !chapter.show) {
throw redirect(303, `/dashboard/chapters`);
redirect(303, `/dashboard/chapters`);
}
if (
!chapter.puzzles.some((puzzle) => puzzle.id === parseInt(puzzleId)) ||
!chapter.puzzles.find((puzzle) => puzzle.id === parseInt(puzzleId))?.show
) {
throw redirect(303, `/dashboard/chapters/${chapterId}`);
redirect(303, `/dashboard/chapters/${chapterId}`);
}
res = await fetch(`${API_URL}/puzzle/${puzzleId}`, {
@ -44,13 +44,13 @@ export const load = (async ({ parent, fetch, cookies, params: { chapterId, puzzl
});
if (!res.ok) {
throw error(404, 'Puzzle not found');
error(404, 'Puzzle not found');
}
const puzzle = await res.json();
if (!puzzle) {
throw error(404, 'Puzzle not found');
error(404, 'Puzzle not found');
}
return {
@ -62,6 +62,6 @@ export const load = (async ({ parent, fetch, cookies, params: { chapterId, puzzl
export const actions = {
default: async ({ params }) => {
throw redirect(303, `/dashboard/chapters/${params.chapterId}/puzzle/${params.puzzleId}`);
redirect(303, `/dashboard/chapters/${params.chapterId}/puzzle/${params.puzzleId}`);
}
} satisfies Actions;

View file

@ -1,5 +1,5 @@
<script lang="ts">
import { cn } from '$lib';
import { cn } from '$lib/utils';
import type { PageData } from './$types';
export let data: PageData;

View file

@ -10,7 +10,7 @@ export const load = (async ({ parent, fetch, cookies, params: { chapterId } }) =
await parent();
if (!chapterId) {
throw redirect(303, '/dashboard');
redirect(303, '/dashboard');
}
const session = cookies.get('session');
@ -22,13 +22,13 @@ export const load = (async ({ parent, fetch, cookies, params: { chapterId } }) =
});
if (!res.ok) {
throw redirect(303, '/dashboard');
redirect(303, '/dashboard');
}
const leaderboard = (await res.json()) as LeaderboardEvent;
if (!leaderboard || !leaderboard.groups.length) {
throw redirect(303, '/dashboard');
redirect(303, '/dashboard');
}
return {

View file

@ -1,5 +1,5 @@
<script lang="ts">
import { cn } from '$lib';
import { cn } from '$lib/utils';
import type { PageData } from './$types';
export let data: PageData;

View file

@ -7,7 +7,7 @@
import Button from '$lib/components/ui/Button.svelte';
import Input from '$lib/components/ui/Input.svelte';
import plausible from '$lib/stores/Plausible';
import plausible from '$lib/stores/plausible';
import { addToast } from '$lib/components/Toaster.svelte';
export let data: PageData;

View file

@ -6,6 +6,7 @@ import type { PageServerLoad } from './$types';
import { superValidate } from 'sveltekit-superforms/server';
import { z } from 'zod';
import { zod } from 'sveltekit-superforms/adapters';
const forgotSchema = z.object({
email: z
@ -43,9 +44,9 @@ const confirmationSchema = z.object({
});
export const load = (async ({ locals: { user } }) => {
if (user) throw redirect(303, '/dashboard');
if (user) redirect(303, '/dashboard');
const form = await superValidate(forgotSchema);
const form = await superValidate(zod(forgotSchema));
return {
form
@ -54,7 +55,7 @@ export const load = (async ({ locals: { user } }) => {
export const actions = {
forgot: async ({ request, cookies }) => {
const form = await superValidate(request, forgotSchema);
const form = await superValidate(request, zod(forgotSchema));
if (!form.valid) {
return fail(400, { form });
@ -77,8 +78,6 @@ export const actions = {
body: JSON.stringify(data)
});
console.log(res);
if (res.ok) {
const token = res.headers.get('Authorization')?.split('Bearer ')[1];
@ -87,21 +86,21 @@ export const actions = {
path: '/'
});
throw redirect(303, '/dashboard');
redirect(303, '/dashboard');
}
return {
form
};
}
form.errors.passwd = ['Code invalide ou expiré'];
form.errors.code = ['Code invalide ou expiré'];
return fail(400, {
form
});
},
confirmation: async ({ request, cookies }) => {
const form = await superValidate(request, confirmationSchema);
const form = await superValidate(request, zod(confirmationSchema));
if (!form.valid) {
return fail(400, { form });
@ -125,7 +124,7 @@ export const actions = {
path: '/'
});
throw redirect(303, '/dashboard');
redirect(303, '/dashboard');
}
form.errors.code = [`Une erreur s'est produite (${res.status} ${res.statusText})`];

View file

@ -30,7 +30,6 @@
});
break;
}
submitting = false;
}
});
@ -58,7 +57,9 @@
type="email"
placeholder="philipzcwbarlow@peerat.dev"
autocomplete="off"
autocorrect="off"
required
aria-invalid={$errors.email ? 'true' : undefined}
/>
{#if $errors.email}<span class="text-sm text-red-500">{$errors.email}</span>{/if}
@ -69,12 +70,26 @@
duration: 300
}}
>
<label for="passwd"> Mot de passe </label>
<Input name="passwd" placeholder="************" type="password" />
<label for="passwd"> Nouveau Mot de passe </label>
<Input
bind:value={$form.passwd}
name="passwd"
placeholder="************"
type="password"
required
aria-invalid={$errors.passwd ? 'true' : undefined}
/>
{#if $errors.passwd}<span class="text-sm text-red-500">{$errors.passwd}</span>{/if}
<label for="code"> Code </label>
<Input name="code" placeholder="1234" type="text" />
<Input
bind:value={$form.code}
name="code"
placeholder="1234"
type="text"
required
aria-invalid={$errors.code ? 'true' : undefined}
/>
{#if $errors.code}<span class="text-sm text-red-500">{$errors.code}</span>{/if}
</div>
{/if}
@ -92,9 +107,9 @@
</li>
{#if confirmation}
<li>
<button formaction="?/register" class="text-highlight-secondary hover:text-brand"
>Pas reçu ?</button
>
<button formaction="?/register" class="text-highlight-secondary hover:text-brand">
Renvoyer le code
</button>
</li>
{/if}
</ul>

View file

@ -9,5 +9,5 @@ export const load: ServerLoad = async ({ cookies, locals }) => {
locals.user = undefined;
throw redirect(303, '/');
redirect(303, '/');
};

View file

@ -1,30 +1,32 @@
import { API_URL } from '$env/static/private';
import { redirect, type Actions, fail } from '@sveltejs/kit';
import { fail, redirect, type Actions } from '@sveltejs/kit';
import type { PageServerLoad } from './$types';
import { zod } from 'sveltekit-superforms/adapters';
import { superValidate } from 'sveltekit-superforms/server';
import { z } from 'zod';
const schema = z.object({
pseudo: z.string().trim(),
passwd: z.string()
});
export const load = (async ({ locals: { user } }) => {
if (user) throw redirect(303, '/dashboard');
if (user) redirect(303, '/dashboard');
const form = await superValidate(schema);
const form = await superValidate(zod(schema));
return {
form
};
}) satisfies PageServerLoad;
const schema = z.object({
pseudo: z.string().trim(),
passwd: z.string()
});
export const actions = {
default: async ({ request, cookies }) => {
const form = await superValidate(request, schema);
const form = await superValidate(request, zod(schema));
if (!form.valid) {
return fail(400, { form });
@ -40,7 +42,12 @@ export const actions = {
if (res.ok) {
const token = res.headers.get('Authorization')?.split(' ')[1];
if (!token) throw new Error('No token found');
if (!token) {
form.errors.passwd = ["Une erreur est survenue, veuillez réessayer plus tard"];
return fail(500, { form });
}
cookies.set('session', token, {
path: '/'

View file

@ -6,6 +6,7 @@ import type { PageServerLoad } from './$types';
import { superValidate } from 'sveltekit-superforms/server';
import { z } from 'zod';
import { zod } from 'sveltekit-superforms/adapters';
const registerSchema = z.object({
email: z
@ -50,9 +51,9 @@ const confirmationSchema = z.object({
});
export const load = (async ({ locals: { user } }) => {
if (user) throw redirect(303, '/dashboard');
if (user) redirect(303, '/dashboard');
const form = await superValidate(registerSchema);
const form = await superValidate(zod(registerSchema));
return {
form
@ -61,7 +62,7 @@ export const load = (async ({ locals: { user } }) => {
export const actions = {
register: async ({ request }) => {
const form = await superValidate(request, registerSchema);
const form = await superValidate(request, zod(registerSchema));
if (!form.valid) {
return fail(400, { form });
@ -99,7 +100,7 @@ export const actions = {
});
},
confirmation: async ({ request, cookies }) => {
const form = await superValidate(request, confirmationSchema);
const form = await superValidate(request, zod(confirmationSchema));
if (!form.valid) {
return fail(400, { form });

View file

@ -1,13 +1,13 @@
<script lang="ts">
import { Loader2 } from 'lucide-svelte';
import { fade } from 'svelte/transition';
import { superForm } from 'sveltekit-superforms/client';
import { Loader2 } from 'lucide-svelte';
import type { PageData, Snapshot } from './$types';
import { addToast } from '$lib/components/Toaster.svelte';
import Button from '$lib/components/ui/Button.svelte';
import Input from '$lib/components/ui/Input.svelte';
import { addToast } from '$lib/components/Toaster.svelte';
export let data: PageData;
@ -63,6 +63,7 @@
type="email"
placeholder="philipzcwbarlow@peerat.dev"
autocomplete="off"
autocorrect="off"
required
aria-invalid={$errors.email ? 'true' : undefined}
/>
@ -75,6 +76,7 @@
type="text"
placeholder="Philip"
autocomplete="off"
autocorrect="off"
required
aria-invalid={$errors.firstname ? 'true' : undefined}
/>
@ -87,6 +89,7 @@
type="text"
placeholder="Barlow"
autocomplete="off"
autocorrect="off"
required
aria-invalid={$errors.lastname ? 'true' : undefined}
/>
@ -99,6 +102,7 @@
type="text"
placeholder="Cypher Wolf"
autocomplete="off"
autocorrect="off"
required
aria-invalid={$errors.pseudo ? 'true' : undefined}
/>
@ -116,6 +120,7 @@
name="passwd"
placeholder="************"
type="password"
required
aria-invalid={$errors.passwd ? 'true' : undefined}
/>
{#if $errors.passwd}<span class="text-sm text-red-500">{$errors.passwd}</span>{/if}
@ -125,6 +130,7 @@
name="code"
placeholder="1234"
type="text"
required
aria-invalid={$errors.code ? 'true' : undefined}
/>
{#if $errors.code}<span class="text-sm text-red-500">{$errors.code}</span>{/if}

View file

@ -1,7 +1,8 @@
import { preprocessMeltUI } from '@melt-ui/pp';
import sequence from 'svelte-sequential-preprocessor';
import adapter from '@sveltejs/adapter-node';
import { vitePreprocess } from '@sveltejs/kit/vite';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
import sequence from 'svelte-sequential-preprocessor';
/** @type {import('@sveltejs/kit').Config}*/
const config = {
// Consult https://kit.svelte.dev/docs/integrations#preprocessors

View file

@ -5,5 +5,8 @@ export default defineConfig({
plugins: [sveltekit()],
test: {
include: ['src/**/*.{test,spec}.{js,ts}']
},
define: {
SUPERFORMS_LEGACY: true
}
});