Changeset 834bcc3 in Klonkt for src/routes/account.js
- Timestamp:
- 06/23/2026 06:14:27 PM (3 months ago)
- Branches:
- main
- Children:
- d774679
- Parents:
- bb42dfb
- File:
-
- 1 edited
-
src/routes/account.js (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/account.js
rbb42dfb r834bcc3 66 66 const hasPassword = !!(account && account.password_hash && account.password_hash !== '!google-oauth'); 67 67 const googleLinked = !!(account && account.google_sub); 68 if (account) { delete account.password_hash; delete account.google_sub; } // niet naar de view lekken68 if (account) { delete account.password_hash; delete account.google_sub; } // don't leak to the view 69 69 70 70 renderPage(req, res, 'pages/account', { … … 81 81 }); 82 82 83 // ==================== PERSO ONLIJKE INTERFACE-TAAL====================84 // S laat de taalkeuze op het account op (reist mee over apparaten/sessies) én85 // zet 'm meteen in de sessie zodat 't direct effect heeft.83 // ==================== PERSONAL INTERFACE LANGUAGE ==================== 84 // Saves the language choice on the account (persists across devices/sessions) and 85 // also sets it in the session immediately so it takes effect right away. 86 86 router.post('/lang', requireAuth, (req, res) => { 87 87 const code = SUPPORTED.includes(req.body.lang) ? req.body.lang : null; … … 94 94 }); 95 95 96 // De site die deze gebruiker mag bewerken vanuit z'n account: z'n eigen site97 // (owner_id), o f voor een god de primaire site. Null als er niets is.96 // The site this user may edit from their account: their own site 97 // (owner_id), or for a god the primary site. Null if nothing found. 98 98 function ownedSite(user) { 99 99 if (!user) return null; 100 100 let site = db.prepare('SELECT id, title, tagline, slug, owner_id FROM sites WHERE owner_id = ? ORDER BY created_at LIMIT 1').get(user.id); 101 101 if (!site && user.role === 'god') { 102 site = getPrimarySite(); // prima ire/hoofd-site als fallback102 site = getPrimarySite(); // primary/main site as fallback 103 103 } 104 104 return site || null; … … 124 124 const bio = (req.body.bio || '').toString().slice(0, 500).trim(); 125 125 126 // E -mail (optioneel mee te wijzigen). Validatie: geldig formaat + niet al door127 // een ander account in gebruik. E-mail is het login-/reset-anker, dus uniek.126 // Email (optionally also changed). Validation: valid format + not already in use 127 // by another account. Email is the login/reset anchor, so it must be unique. 128 128 const email = (req.body.email || '').toString().trim(); 129 129 if (email) { … … 138 138 db.prepare('UPDATE users SET email = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ?') 139 139 .run(email, req.session.user.id); 140 req.session.user.email = email; // sessie bijwerken zodat de UI klopt140 req.session.user.email = email; // update session so the UI reflects the change 141 141 } 142 142 … … 166 166 167 167 const row = db.prepare('SELECT password_hash FROM users WHERE id = ?').get(req.session.user.id); 168 // Google-only accounts (l uisteraars) hebben geen echt wachtwoord.168 // Google-only accounts (listeners) have no real password. 169 169 if (!row || !row.password_hash || row.password_hash === '!google-oauth') { 170 170 return res.redirect('/account?error=' + encodeURIComponent('Dit account heeft geen wachtwoord (Google-login)')); … … 181 181 }); 182 182 183 // Google-account ontkoppelen. Alleen toegestaan als er nog een wachtwoord is,184 // anders zou je jezelf buitensluiten (geen login-methode meer over).183 // Unlink Google account. Only allowed if a password is set, 184 // otherwise the user would lock themselves out (no login method left). 185 185 router.post('/google/unlink', requireAuth, (req, res) => { 186 186 const row = db.prepare('SELECT password_hash, google_sub FROM users WHERE id = ?').get(req.session.user.id);
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)