fixed uuid conflicts
This commit is contained in:
parent
ce0d940953
commit
d0e03d44f7
3 changed files with 54 additions and 4 deletions
BIN
prisma/dev.db
BIN
prisma/dev.db
Binary file not shown.
|
|
@ -1,15 +1,16 @@
|
||||||
import { prisma } from '$lib/server/prisma';
|
import { prisma } from '$lib/server/prisma';
|
||||||
|
import type { Session } from 'lucia';
|
||||||
|
|
||||||
export async function load(event) {
|
export async function load(event: Session) {
|
||||||
const userId = event.cookies.get('user');
|
const userId = event.userId;
|
||||||
if (!userId && isNaN(Number(userId))) {
|
if (!userId) {
|
||||||
return {
|
return {
|
||||||
authenticated: false
|
authenticated: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const user = await prisma.user.findUnique({
|
const user = await prisma.user.findUnique({
|
||||||
where: {
|
where: {
|
||||||
id: Number(userId)
|
id: userId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
49
src/routes/login/+page.svelte
Normal file
49
src/routes/login/+page.svelte
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
<script lang="ts">
|
||||||
|
import Button from '$lib/components/Button.svelte';
|
||||||
|
import Input from '$lib/components/Input.svelte';
|
||||||
|
import { fade, scale } from 'svelte/transition';
|
||||||
|
|
||||||
|
let mode: 'register' | 'login' = $state('login');
|
||||||
|
let action = $derived(mode === 'login' ? '?/login' : '?/register');
|
||||||
|
|
||||||
|
function onViewToggle() {
|
||||||
|
mode = mode === 'login' ? 'register' : 'login';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="page">
|
||||||
|
<h1 class="underline">Hestia</h1>
|
||||||
|
<div class="login">
|
||||||
|
<form method="POST" {action} transition:scale>
|
||||||
|
<h2 transition:fade>{mode === 'login' ? 'Login' : 'Register'}</h2>
|
||||||
|
{#if mode === 'register'}
|
||||||
|
<div transition:fade>
|
||||||
|
<Input label="Name" name="name" />
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
<Input label="Email" name="email" type="email" />
|
||||||
|
<Input label="Password" name="password" type="password" />
|
||||||
|
<div class="flex gap-2">
|
||||||
|
<Button
|
||||||
|
onClick={onViewToggle}
|
||||||
|
label={mode === 'login' ? 'Register' : 'Login'}
|
||||||
|
size="large"
|
||||||
|
primary
|
||||||
|
/>
|
||||||
|
<Button type="submit" label="Submit" size="large" />
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.page {
|
||||||
|
@apply flex flex-col items-center justify-around gap-24 py-[10%];
|
||||||
|
}
|
||||||
|
.login {
|
||||||
|
@apply w-fit max-w-lg animate-fade rounded-lg bg-white p-8;
|
||||||
|
}
|
||||||
|
.login > form {
|
||||||
|
@apply flex w-full flex-col items-center gap-8 rounded-lg;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Loading…
Add table
Reference in a new issue