Changeset 82079ad in Klonkt for src/routes/account.js


Ignore:
Timestamp:
06/24/2026 12:31:43 PM (3 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
3d7312a
Parents:
52ea6df
Message:

feat: one identity — user avatar falls back to the site photo everywhere

When a user has no own account avatar, display their site's profile photo across
the account page, top nav (render.js) and comments. No DB copy → stays in sync.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/routes/account.js

    r52ea6df r82079ad  
    6868  if (account) { delete account.password_hash; delete account.google_sub; } // don't leak to the view
    6969
     70  const editableSite = ownedSite(req.session.user);
    7071  renderPage(req, res, 'pages/account', {
    7172    pageTitle: 'Account',
     
    7576    googleLinked,
    7677    googleAvailable: googleConfigured(),
    77     editableSite: ownedSite(req.session.user),
     78    editableSite,
     79    // Display fallback: when you have no own account avatar, show your site's photo.
     80    siteAvatar: editableSite ? editableSite.profile_photo : null,
    7881    success: req.query.success || null,
    7982    error: req.query.error || null,
     
    98101function ownedSite(user) {
    99102  if (!user) return null;
    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);
     103  let site = db.prepare('SELECT id, title, tagline, slug, owner_id, profile_photo FROM sites WHERE owner_id = ? ORDER BY created_at LIMIT 1').get(user.id);
    101104  if (!site && user.role === 'god') {
    102105    site = getPrimarySite(); // primary/main site as fallback
Note: See TracChangeset for help on using the changeset viewer.