Lucia Authentication #8

Merged
DanMihailescu merged 18 commits from undoPretty into master 2024-12-19 20:06:45 -05:00
5 changed files with 35 additions and 37 deletions
Showing only changes of commit ea0ce134fe - Show all commits

Binary file not shown.

View file

@ -30,7 +30,7 @@ model Session {
id String @id @default(uuid())
expiresAt DateTime
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
updatedAt DateTime @default(now()) @updatedAt
userId String
user User @relation(references: [id], fields: [userId])
}
@ -41,7 +41,7 @@ model Post {
title String
content String
published Boolean? @default(false)
author User @relation(fields: [authorId], references: [id])
author User @relation(references: [id], fields: [authorId])
authorId String
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt

View file

@ -1,32 +1,32 @@
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
import { Lucia } from "lucia";
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
import { PrismaAdapter } from "@lucia-auth/adapter-prisma";
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
import { PrismaClient } from "@prisma/client";
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
import { Lucia } from 'lucia';
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
import { PrismaAdapter } from '@lucia-auth/adapter-prisma';
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
import { prisma } from '$lib/server/prisma';
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
const client = new PrismaClient();
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
const adapter = new PrismaAdapter(client.session, client.user)
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
const client = prisma;
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
const adapter = new PrismaAdapter(client.session, client.user);
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
// expect error (see next section)
export const auth = new Lucia(adapter, {
sessionCookie: {
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
attributes: {
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
secure: process.env.NODE_ENV === "production"
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
}
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
},
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
getUserAttributes: (attributes)=>{
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
return {
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
email: attributes.email
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
}
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
}
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
sessionCookie: {
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
attributes: {
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
secure: process.env.NODE_ENV === 'production'
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
}
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
},
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
getUserAttributes: (attributes) => {
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
return {
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
email: attributes.email
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
};
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
}
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
});
declare module "lucia" {
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
interface Register {
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
Lucia: typeof Lucia;
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
DatabaseUserAttributes: DatabaseUserAttributes
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
}
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
declare module 'lucia' {
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
interface Register {
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
Lucia: typeof Lucia;
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
DatabaseUserAttributes: DatabaseUserAttributes;
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
}
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
}
interface DatabaseUserAttributes {
email: string
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
email: string;
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
}
export type Auth = typeof auth;
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
export type Auth = typeof auth;
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...

BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...
BenjaminPalko commented 2024-12-17 14:11:26 -05:00 (Migrated from github.com)
Review

Reuse the $lib/server/prisma client plz

Reuse the `$lib/server/prisma` client plz
BenjaminPalko commented 2024-12-18 12:33:08 -05:00 (Migrated from github.com)
Review

You dont need to set it to a const...

You dont need to set it to a const...

View file

@ -1,6 +1,6 @@
BenjaminPalko commented 2024-12-17 14:14:38 -05:00 (Migrated from github.com)
Review

I dont think you can type event as a a Session, from the app typedefs you made it should be event.locals.[session or user idk]

I dont think you can type event as a a Session, from the app typedefs you made it should be _event.locals.[session or user idk]_
BenjaminPalko commented 2024-12-17 14:14:57 -05:00 (Migrated from github.com)
Review
https://github.com/Machinata/hestia/pull/8/files#diff-b07092d78bfaa239d6ad0d01b0897c3ef49533b08512622d83c6f4e1dd3b363e
DanMihailescu commented 2024-12-18 10:07:50 -05:00 (Migrated from github.com)
Review

switched back to any type

switched back to any type
BenjaminPalko commented 2024-12-18 12:34:07 -05:00 (Migrated from github.com)
Review

Use the logger pls

Use the logger pls
BenjaminPalko commented 2024-12-17 14:14:38 -05:00 (Migrated from github.com)
Review

I dont think you can type event as a a Session, from the app typedefs you made it should be event.locals.[session or user idk]

I dont think you can type event as a a Session, from the app typedefs you made it should be _event.locals.[session or user idk]_
BenjaminPalko commented 2024-12-17 14:14:57 -05:00 (Migrated from github.com)
Review
https://github.com/Machinata/hestia/pull/8/files#diff-b07092d78bfaa239d6ad0d01b0897c3ef49533b08512622d83c6f4e1dd3b363e
DanMihailescu commented 2024-12-18 10:07:50 -05:00 (Migrated from github.com)
Review

switched back to any type

switched back to any type
BenjaminPalko commented 2024-12-18 12:34:07 -05:00 (Migrated from github.com)
Review

Use the logger pls

Use the logger pls
import { prisma } from '$lib/server/prisma';
import type { Session } from 'lucia';
BenjaminPalko commented 2024-12-17 14:14:38 -05:00 (Migrated from github.com)
Review

I dont think you can type event as a a Session, from the app typedefs you made it should be event.locals.[session or user idk]

I dont think you can type event as a a Session, from the app typedefs you made it should be _event.locals.[session or user idk]_
BenjaminPalko commented 2024-12-17 14:14:57 -05:00 (Migrated from github.com)
Review
https://github.com/Machinata/hestia/pull/8/files#diff-b07092d78bfaa239d6ad0d01b0897c3ef49533b08512622d83c6f4e1dd3b363e
DanMihailescu commented 2024-12-18 10:07:50 -05:00 (Migrated from github.com)
Review

switched back to any type

switched back to any type
BenjaminPalko commented 2024-12-18 12:34:07 -05:00 (Migrated from github.com)
Review

Use the logger pls

Use the logger pls
export async function load(event: Session) {
BenjaminPalko commented 2024-12-17 14:14:38 -05:00 (Migrated from github.com)
Review

I dont think you can type event as a a Session, from the app typedefs you made it should be event.locals.[session or user idk]

I dont think you can type event as a a Session, from the app typedefs you made it should be _event.locals.[session or user idk]_
BenjaminPalko commented 2024-12-17 14:14:57 -05:00 (Migrated from github.com)
Review
https://github.com/Machinata/hestia/pull/8/files#diff-b07092d78bfaa239d6ad0d01b0897c3ef49533b08512622d83c6f4e1dd3b363e
DanMihailescu commented 2024-12-18 10:07:50 -05:00 (Migrated from github.com)
Review

switched back to any type

switched back to any type
BenjaminPalko commented 2024-12-18 12:34:07 -05:00 (Migrated from github.com)
Review

Use the logger pls

Use the logger pls
export async function load(event) {
BenjaminPalko commented 2024-12-17 14:14:38 -05:00 (Migrated from github.com)
Review

I dont think you can type event as a a Session, from the app typedefs you made it should be event.locals.[session or user idk]

I dont think you can type event as a a Session, from the app typedefs you made it should be _event.locals.[session or user idk]_
BenjaminPalko commented 2024-12-17 14:14:57 -05:00 (Migrated from github.com)
Review
https://github.com/Machinata/hestia/pull/8/files#diff-b07092d78bfaa239d6ad0d01b0897c3ef49533b08512622d83c6f4e1dd3b363e
DanMihailescu commented 2024-12-18 10:07:50 -05:00 (Migrated from github.com)
Review

switched back to any type

switched back to any type
BenjaminPalko commented 2024-12-18 12:34:07 -05:00 (Migrated from github.com)
Review

Use the logger pls

Use the logger pls
console.log(event.userId);
BenjaminPalko commented 2024-12-17 14:14:38 -05:00 (Migrated from github.com)
Review

I dont think you can type event as a a Session, from the app typedefs you made it should be event.locals.[session or user idk]

I dont think you can type event as a a Session, from the app typedefs you made it should be _event.locals.[session or user idk]_
BenjaminPalko commented 2024-12-17 14:14:57 -05:00 (Migrated from github.com)
Review
https://github.com/Machinata/hestia/pull/8/files#diff-b07092d78bfaa239d6ad0d01b0897c3ef49533b08512622d83c6f4e1dd3b363e
DanMihailescu commented 2024-12-18 10:07:50 -05:00 (Migrated from github.com)
Review

switched back to any type

switched back to any type
BenjaminPalko commented 2024-12-18 12:34:07 -05:00 (Migrated from github.com)
Review

Use the logger pls

Use the logger pls
const userId = event.userId;
if (!userId) {
return {

BenjaminPalko commented 2024-12-17 14:14:38 -05:00 (Migrated from github.com)
Review

I dont think you can type event as a a Session, from the app typedefs you made it should be event.locals.[session or user idk]

I dont think you can type event as a a Session, from the app typedefs you made it should be _event.locals.[session or user idk]_
BenjaminPalko commented 2024-12-17 14:14:57 -05:00 (Migrated from github.com)
Review
https://github.com/Machinata/hestia/pull/8/files#diff-b07092d78bfaa239d6ad0d01b0897c3ef49533b08512622d83c6f4e1dd3b363e
DanMihailescu commented 2024-12-18 10:07:50 -05:00 (Migrated from github.com)
Review

switched back to any type

switched back to any type
BenjaminPalko commented 2024-12-18 12:34:07 -05:00 (Migrated from github.com)
Review

Use the logger pls

Use the logger pls
BenjaminPalko commented 2024-12-17 14:14:38 -05:00 (Migrated from github.com)
Review

I dont think you can type event as a a Session, from the app typedefs you made it should be event.locals.[session or user idk]

I dont think you can type event as a a Session, from the app typedefs you made it should be _event.locals.[session or user idk]_
BenjaminPalko commented 2024-12-17 14:14:57 -05:00 (Migrated from github.com)
Review
https://github.com/Machinata/hestia/pull/8/files#diff-b07092d78bfaa239d6ad0d01b0897c3ef49533b08512622d83c6f4e1dd3b363e
DanMihailescu commented 2024-12-18 10:07:50 -05:00 (Migrated from github.com)
Review

switched back to any type

switched back to any type
BenjaminPalko commented 2024-12-18 12:34:07 -05:00 (Migrated from github.com)
Review

Use the logger pls

Use the logger pls

View file

@ -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,13 @@ 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 password = form.get('password') as string;
const hashedPassword = await new Argon2id().hash(password);
const user = await prisma.user.create({
data: {
email: form.get('email') as string,
@ -61,6 +60,5 @@ export const actions = {
maxAge: 120
});
redirect(302, '/');
}
} satisfies Actions;
} satisfies Actions;