feat: Display login success messages, adjust user registration defaults and post-registration redirect, and include scripts for generating dummy items and copying thumbnails.

This commit is contained in:
x
2026-01-24 16:11:56 +01:00
parent 16da3ac9d0
commit 2ad318e7c5
2 changed files with 32 additions and 7 deletions

View File

@@ -47,7 +47,7 @@ export default (router, tpl) => {
const newUser = await db`
insert into "user" ("login", "password", "user", "created_at", "admin")
values (${username.toLowerCase()}, ${hash}, ${username}, ${ts}, false)
values (${username.toLowerCase()}, ${hash}, ${username}, to_timestamp(${ts}), false)
returning id
`;
const userId = newUser[0].id;
@@ -59,17 +59,17 @@ export default (router, tpl) => {
where id = ${tokenRow[0].id}
`;
// Get a valid avatar ID (default to 1 or whatever exists)
const avatarRow = await db`select id from items limit 1`;
const avatarId = avatarRow.length > 0 ? avatarRow[0].id : 1; // Fallback to 1, though checking length is safer
// Get a valid avatar ID (default to 1)
const avatarRow = await db`select id from items where id = 1`;
const avatarId = avatarRow.length > 0 ? 1 : (await db`select id from items limit 1`)[0].id;
await db`
insert into user_options (user_id, mode, theme, fullscreen, avatar)
values (${userId}, 0, 'f0ck', 0, ${avatarId})
values (${userId}, 3, 'amoled', 0, ${avatarId})
`;
// Redirect to login
return res.writeHead(302, { "Location": "/login" }).end();
// Redirect to home with login success message
return res.writeHead(302, { "Location": "/?login=success" }).end();
});
return router;