Changeset 6d882b1 in Klonkt
- Timestamp:
- 06/20/2026 01:24:26 AM (3 months ago)
- Branches:
- main
- Children:
- dfc5379
- Parents:
- 11ba289
- Location:
- src
- Files:
-
- 2 edited
-
routes/account.js (modified) (1 diff)
-
views/pages/account.ejs (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 -
src/views/pages/account.ejs
r11ba289 r6d882b1 69 69 <form action="/account/profile" method="post" class="ax-form ax-form-bio"> 70 70 <label class="ax-field"> 71 <span>E-mailadres</span> 72 <input type="email" name="email" value="<%= account.email || '' %>" maxlength="254" autocomplete="email" placeholder="jij@email.nl"> 73 </label> 74 <label class="ax-field"> 71 75 <span>Bio</span> 72 76 <textarea name="bio" rows="3" maxlength="500" placeholder="Een korte regel over jezelf"><%= account.bio || '' %></textarea> 73 77 </label> 74 78 <div class="ax-form-actions"> 75 <button type="submit" class="ax-btn ax-btn-primary"> Bio opslaan</button>79 <button type="submit" class="ax-btn ax-btn-primary">Opslaan</button> 76 80 </div> 77 81 </form>
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)