pretty
This commit is contained in:
parent
f0f32d71fc
commit
ce0d940953
35 changed files with 62 additions and 66 deletions
|
|
@ -13,4 +13,4 @@ const config = {
|
|||
options: {}
|
||||
}
|
||||
};
|
||||
export default config;
|
||||
export default config;
|
||||
|
|
|
|||
|
|
@ -10,4 +10,4 @@ const preview = {
|
|||
}
|
||||
};
|
||||
|
||||
export default preview;
|
||||
export default preview;
|
||||
|
|
|
|||
|
|
@ -16,4 +16,4 @@ h2 {
|
|||
|
||||
h3 {
|
||||
@apply font-display text-2xl;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
3
src/app.d.ts
vendored
3
src/app.d.ts
vendored
|
|
@ -2,10 +2,9 @@
|
|||
// for information about these interfaces
|
||||
declare global {
|
||||
namespace App {
|
||||
|
||||
// interface Error {}
|
||||
interface Locals {
|
||||
user: import("lucia").User | null;
|
||||
user: import('lucia').User | null;
|
||||
session: import('lucia').Session | null;
|
||||
}
|
||||
// interface PageData {}
|
||||
|
|
|
|||
|
|
@ -27,4 +27,4 @@
|
|||
});
|
||||
</script>
|
||||
|
||||
<Story name="Default" args={{ label: 'Button', size: 'normal', primary: true }} />
|
||||
<Story name="Default" args={{ label: 'Button', size: 'normal', primary: true }} />
|
||||
|
|
|
|||
|
|
@ -48,4 +48,4 @@
|
|||
.button--secondary {
|
||||
@apply bg-blue-600 text-white;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -40,4 +40,4 @@
|
|||
|
||||
<Story name="Text" args={{ label: 'Text', name: 'text', type: 'text' }} />
|
||||
<Story name="Password" args={{ label: 'Password', name: 'pass', type: 'password' }} />
|
||||
<Story name="Email" args={{ label: 'Email', name: 'email', type: 'email' }} />
|
||||
<Story name="Email" args={{ label: 'Email', name: 'email', type: 'email' }} />
|
||||
|
|
|
|||
|
|
@ -33,4 +33,4 @@
|
|||
all: unset;
|
||||
@apply text-lg;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -9,4 +9,4 @@
|
|||
});
|
||||
</script>
|
||||
|
||||
<Story name="Default" args={{}} />
|
||||
<Story name="Default" args={{}} />
|
||||
|
|
|
|||
|
|
@ -48,4 +48,4 @@
|
|||
transform: rotate(-360deg);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -9,4 +9,4 @@
|
|||
});
|
||||
</script>
|
||||
|
||||
<Story name="Default" args={{ title: 'Storybook' }} />
|
||||
<Story name="Default" args={{ title: 'Storybook' }} />
|
||||
|
|
|
|||
|
|
@ -28,4 +28,4 @@
|
|||
.navbar h2 {
|
||||
@apply text-xl;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
export * from './Navbar.svelte';
|
||||
export * from './Navbar.svelte';
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
// place files you want to import through the `$lib` alias in this folder.
|
||||
export * from './components';
|
||||
export * from './components';
|
||||
|
|
|
|||
|
|
@ -21,4 +21,4 @@ export const LoadConfig = (): Configuration => {
|
|||
};
|
||||
};
|
||||
|
||||
export const Config = LoadConfig();
|
||||
export const Config = LoadConfig();
|
||||
|
|
|
|||
|
|
@ -20,4 +20,4 @@ export const yogaLogger: YogaLogger = {
|
|||
// @ts-expect-error types dont match
|
||||
logger.error(...args);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,32 +1,32 @@
|
|||
import { Lucia } from "lucia";
|
||||
import { PrismaAdapter } from "@lucia-auth/adapter-prisma";
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import { Lucia } from 'lucia';
|
||||
import { PrismaAdapter } from '@lucia-auth/adapter-prisma';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
const client = new PrismaClient();
|
||||
const adapter = new PrismaAdapter(client.session, client.user)
|
||||
const adapter = new PrismaAdapter(client.session, client.user);
|
||||
// expect error (see next section)
|
||||
export const auth = new Lucia(adapter, {
|
||||
sessionCookie: {
|
||||
attributes: {
|
||||
secure: process.env.NODE_ENV === "production"
|
||||
}
|
||||
},
|
||||
getUserAttributes: (attributes)=>{
|
||||
return {
|
||||
email: attributes.email
|
||||
}
|
||||
}
|
||||
sessionCookie: {
|
||||
attributes: {
|
||||
secure: process.env.NODE_ENV === 'production'
|
||||
}
|
||||
},
|
||||
getUserAttributes: (attributes) => {
|
||||
return {
|
||||
email: attributes.email
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
declare module "lucia" {
|
||||
interface Register {
|
||||
Lucia: typeof Lucia;
|
||||
DatabaseUserAttributes: DatabaseUserAttributes
|
||||
}
|
||||
declare module 'lucia' {
|
||||
interface Register {
|
||||
Lucia: typeof Lucia;
|
||||
DatabaseUserAttributes: DatabaseUserAttributes;
|
||||
}
|
||||
}
|
||||
|
||||
interface DatabaseUserAttributes {
|
||||
email: string
|
||||
email: string;
|
||||
}
|
||||
|
||||
export type Auth = typeof auth;
|
||||
export type Auth = typeof auth;
|
||||
|
|
|
|||
|
|
@ -25,4 +25,4 @@ export const builder = new SchemaBuilder<PothosType>({
|
|||
// warn when not using a query parameter correctly
|
||||
onUnusedQuery: process.env.NODE_ENV === 'production' ? null : 'warn'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
export * from './schema';
|
||||
export * from './schema';
|
||||
|
|
|
|||
|
|
@ -11,4 +11,4 @@ export const DateScalar = builder.scalarType('Date', {
|
|||
}
|
||||
return new Date(date);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -5,4 +5,4 @@ export type Scalars = {
|
|||
Input: Date;
|
||||
Output: Date;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -15,4 +15,4 @@ import './Scalars';
|
|||
import './posts';
|
||||
import './users';
|
||||
|
||||
export const Schema = builder.toSchema();
|
||||
export const Schema = builder.toSchema();
|
||||
|
|
|
|||
|
|
@ -107,4 +107,4 @@ builder.mutationFields((t) => ({
|
|||
return post;
|
||||
}
|
||||
})
|
||||
}));
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -80,4 +80,4 @@ builder.mutationFields((t) => ({
|
|||
return post;
|
||||
}
|
||||
})
|
||||
}));
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
export const prisma = new PrismaClient();
|
||||
export const prisma = new PrismaClient();
|
||||
|
|
|
|||
|
|
@ -4,4 +4,4 @@ import type { YogaInitialContext } from 'graphql-yoga';
|
|||
export const Context = (initialContext: YogaInitialContext) => ({
|
||||
...initialContext,
|
||||
config: Config
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
export * from './context';
|
||||
export * from './server';
|
||||
export * from './server';
|
||||
|
|
|
|||
|
|
@ -11,4 +11,4 @@ export const Yoga = createYoga<RequestEvent>({
|
|||
// Let Yoga use sveltekit's Response object
|
||||
fetchAPI: { Response },
|
||||
logging: yogaLogger
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -11,4 +11,4 @@
|
|||
.layout {
|
||||
@apply h-screen w-screen animate-fade bg-slate-100;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -15,4 +15,4 @@ export async function load(event) {
|
|||
return {
|
||||
authenticated: !!user
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,4 +21,4 @@
|
|||
.site-loader {
|
||||
@apply flex h-screen w-screen flex-col items-center justify-center gap-6;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
import { Yoga } from '$lib/server/yoga';
|
||||
|
||||
export { Yoga as GET, Yoga as POST };
|
||||
export { Yoga as GET, Yoga as POST };
|
||||
|
|
|
|||
|
|
@ -5,4 +5,4 @@
|
|||
</script>
|
||||
|
||||
<Navbar title="Svelte" />
|
||||
{@render children()}
|
||||
{@render children()}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { logger } from '$lib/server/logger';
|
||||
import { prisma } from '$lib/server/prisma';
|
||||
import { error, redirect, type Actions } from '@sveltejs/kit';
|
||||
import { Argon2id } from "oslo/password"
|
||||
import { Argon2id } from 'oslo/password';
|
||||
import { auth } from '$lib/server/lucia.js';
|
||||
|
||||
export const actions = {
|
||||
|
|
@ -19,12 +19,12 @@ export const actions = {
|
|||
logger.error('User not found! ${user}');
|
||||
return error(401);
|
||||
}
|
||||
const pw = form.get('password') as string;
|
||||
if(!pw) {
|
||||
return error(401, 'Password is required')
|
||||
const password = form.get('password') as string;
|
||||
if (!password) {
|
||||
return error(401, 'Password is required');
|
||||
}
|
||||
const validPassword = await new Argon2id().verify(user.password,pw);
|
||||
if(!validPassword) {
|
||||
const validPassword = await new Argon2id().verify(user.password, password);
|
||||
if (!validPassword) {
|
||||
return error(400, 'Password is incorrect!');
|
||||
}
|
||||
const session = await auth.createSession(user.id, []);
|
||||
|
|
@ -36,14 +36,12 @@ export const actions = {
|
|||
redirect(302, '/');
|
||||
},
|
||||
|
||||
|
||||
|
||||
register: async (event) => {
|
||||
const form = await event.request.formData();
|
||||
if (!form.has('email') || !form.has('name') || !form.has('password')) {
|
||||
return error(400);
|
||||
}
|
||||
const hashedPassword = await new Argon2id().hash(form.get('password') as string)
|
||||
const hashedPassword = await new Argon2id().hash(form.get('password') as string);
|
||||
const user = await prisma.user.create({
|
||||
data: {
|
||||
email: form.get('email') as string,
|
||||
|
|
@ -61,6 +59,5 @@ export const actions = {
|
|||
maxAge: 120
|
||||
});
|
||||
redirect(302, '/');
|
||||
|
||||
}
|
||||
} satisfies Actions;
|
||||
} satisfies Actions;
|
||||
|
|
|
|||
|
|
@ -22,4 +22,4 @@ export default {
|
|||
},
|
||||
|
||||
plugins: [typography]
|
||||
} satisfies Config;
|
||||
} satisfies Config;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue