Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Bit-Barron committed Oct 28, 2024
1 parent 8828612 commit 9ab6454
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/hooks.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ export const handle: Handle = async ({ event, resolve }) => {
if (session && session.fresh) {
const sessionCookie = lucia.createSessionCookie(session.id);
event.cookies.set(sessionCookie.name, sessionCookie.value, {
path: '.',
path: '/',
...sessionCookie.attributes
});
}

if (!session) {
const sessionCookie = lucia.createBlankSessionCookie();
event.cookies.set(sessionCookie.name, sessionCookie.value, {
path: '.',
path: '/',
...sessionCookie.attributes
});
}

event.locals.user = user;
event.locals.session = session;
return resolve(event);
Expand Down
2 changes: 0 additions & 2 deletions src/routes/(auth)/login/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ export const actions: Actions = {
where: { email }
});

console.log(user);

const validPassword = user ? await new Argon2id().verify(user.password, password) : false;

if (!user || !validPassword) {
Expand Down
12 changes: 9 additions & 3 deletions src/routes/(auth)/register/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export const actions = {
const data = Object.fromEntries(formData) as Record<string, string>;

const result = loginSchema.safeParse(data);

if (!result.success) {
return fail(400, {
success: false,
message: 'Validation failed',
errors: result.error.flatten().fieldErrors,
data: { email: data.email }
Expand All @@ -29,8 +29,11 @@ export const actions = {

if (existingUser) {
return fail(400, {
success: false,
message: 'Email already registered',
errors: { email: ['Email already in use'] },
errors: {
email: ['Email already in use']
},
data: { email }
});
}
Expand Down Expand Up @@ -63,8 +66,11 @@ export const actions = {
}

return fail(500, {
success: false,
message: 'An error occurred during registration',
errors: { server: ['Internal server error'] }
errors: {
server: ['Internal server error']
}
});
}
}
Expand Down
Empty file.
Empty file.

0 comments on commit 9ab6454

Please sign in to comment.