settings and fixes
ci / deploy (push) Blocked by required conditions
ci / docker_image (push) Has been cancelled

This commit is contained in:
2026-04-04 17:37:17 -05:00
parent a0efc6c628
commit 3925f4e67a
16 changed files with 217 additions and 71 deletions
+5 -4
View File
@@ -14,8 +14,6 @@ export const load: PageServerLoad = async ({ locals }) => {
SELECT * FROM users WHERE id = ${locals.user.id}
`;
console.log(userData);
return { userData };
};
@@ -47,7 +45,7 @@ export const actions: Actions = {
if (newPassword !== retypeNewPassword) {
fail(400, { password: 'New passwords dont match!' });
}
const passwordHash = await bcrypt.hash(newPassword!, 12);
const passwordHash = newPassword ? await bcrypt.hash(newPassword, 12) : null;
const settings: UserSettings = {
staleItemDays,
@@ -58,12 +56,15 @@ export const actions: Actions = {
return await sql`
UPDATE users SET name = ${name},
email = ${email},
password_hash = ${passwordHash},
${passwordHash ? sql`password_hash = ${passwordHash},` : sql``}
settings = ${settings.toString()}
WHERE id = ${locals.user.id}
RETURNING *;
`;
} catch (e) {
console.log('fails');
console.log(e);
return fail(400, {
message: e instanceof Error ? e.message : 'Unknown error occurred',
success: false