Changeset 6d882b1 in Klonkt for src/routes/account.js
- Timestamp:
- 06/20/2026 01:24:26 AM (3 months ago)
- Branches:
- main
- Children:
- dfc5379
- Parents:
- 11ba289
- File:
-
- 1 edited
-
src/routes/account.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/account.js
r11ba289 r6d882b1 108 108 router.post('/profile', requireAuth, (req, res) => { 109 109 const bio = (req.body.bio || '').toString().slice(0, 500).trim(); 110 111 // E-mail (optioneel mee te wijzigen). Validatie: geldig formaat + niet al door 112 // een ander account in gebruik. E-mail is het login-/reset-anker, dus uniek. 113 const email = (req.body.email || '').toString().trim(); 114 if (email) { 115 if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email) || email.length > 254) { 116 return res.redirect('/account?error=' + encodeURIComponent('Voer een geldig e-mailadres in.')); 117 } 118 const taken = db.prepare('SELECT 1 FROM users WHERE LOWER(email) = LOWER(?) AND id != ?') 119 .get(email, req.session.user.id); 120 if (taken) { 121 return res.redirect('/account?error=' + encodeURIComponent('Dit e-mailadres is al in gebruik.')); 122 } 123 db.prepare('UPDATE users SET email = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ?') 124 .run(email, req.session.user.id); 125 req.session.user.email = email; // sessie bijwerken zodat de UI klopt 126 } 127 110 128 db.prepare('UPDATE users SET bio = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ?') 111 129 .run(bio || null, req.session.user.id); 112 res.redirect('/account?success=' + encodeURIComponent('Profi le updated'));130 res.redirect('/account?success=' + encodeURIComponent('Profiel bijgewerkt')); 113 131 }); 114 132
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)