cleaner nullable name
All checks were successful
Deploy to Server / deploy (push) Successful in 33s

This commit is contained in:
2026-04-10 21:22:31 -05:00
parent 508b1e8169
commit 8d9066d229
2 changed files with 23 additions and 4 deletions

View File

@@ -11,6 +11,18 @@ const uploadsDir = process.env.UPLOADS_DIR || path.join(__dirname, '../../upload
const router = Router();
router.use(requireAuth);
// POST /api/account/name — update (or clear) the authenticated user's display name
router.post('/name', async (req, res) => {
const { name } = req.body;
const cleanName = typeof name === 'string' && name.trim() !== '' ? name.trim() : null;
try {
await pool.query('UPDATE "user" SET name = $1 WHERE id = $2', [cleanName, req.user!.id]);
res.json({ name: cleanName });
} catch {
res.status(500).json({ error: 'Failed to update name' });
}
});
// POST /api/account/delete
router.post('/delete', async (req, res) => {
const userId = req.user!.id;