Changeset 075185a in Klonkt for src/routes/account.js
- Timestamp:
- 06/24/2026 02:16:57 PM (3 months ago)
- Branches:
- main
- Children:
- 2e9773f
- Parents:
- 5b47619
- File:
-
- 1 edited
-
src/routes/account.js (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/account.js
r5b47619 r075185a 24 24 import { renderPage } from '../middleware/render.js'; 25 25 import { requireAuth } from '../middleware/auth.js'; 26 import { googleConfigured } from '../config/google.js';27 26 import { toWebp } from '../services/ImageWebpService.js'; 28 27 import { SUPPORTED } from '../services/i18n.js'; … … 65 64 `).get(req.session.user.id); 66 65 const hasPassword = !!(account && account.password_hash && account.password_hash !== '!google-oauth'); 67 const googleLinked = !!(account && account.google_sub);68 66 if (account) { delete account.password_hash; delete account.google_sub; } // don't leak to the view 69 67 … … 74 72 account, 75 73 hasPassword, 76 googleLinked,77 googleAvailable: googleConfigured(),78 74 editableSite, 79 75 // Display fallback: when you have no own account avatar, show your site's photo. … … 204 200 }); 205 201 206 // Unlink Google account. Only allowed if a password is set,207 // otherwise the user would lock themselves out (no login method left).208 router.post('/google/unlink', requireAuth, (req, res) => {209 const row = db.prepare('SELECT password_hash, google_sub FROM users WHERE id = ?').get(req.session.user.id);210 if (!row || !row.google_sub) {211 return res.redirect('/account?error=' + encodeURIComponent('Er is geen Google-account gekoppeld'));212 }213 if (!row.password_hash || row.password_hash === '!google-oauth') {214 return res.redirect('/account?error=' + encodeURIComponent('Stel eerst een wachtwoord in — anders kun je niet meer inloggen.'));215 }216 db.prepare('UPDATE users SET google_sub = NULL, updated_at = CURRENT_TIMESTAMP WHERE id = ?').run(req.session.user.id);217 res.redirect('/account?success=' + encodeURIComponent('Google-account ontkoppeld'));218 });219 220 202 // ==================== UPLOAD AVATAR ==================== 221 203 router.post('/avatar', requireAuth, (req, res) => {
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)