Changeset d48ea02 in Klonkt


Ignore:
Timestamp:
07/21/2026 01:38:37 AM (7 weeks ago)
Author:
Robin <roboburr@…>
Branches:
main
Children:
e685f55
Parents:
6cbd014
git-author:
Robin <roboburr@…> (07/21/2026 01:38:23 AM)
git-committer:
Robin <roboburr@…> (07/21/2026 01:38:37 AM)
Message:

Fix: paid gate wins from the fan gate (no more login page on paid posts)

A post that is both fan_only and paid sent anonymous visitors to the
fan login gate, because the fan gate was checked first. They never saw
the unlock button. A paid post unlocks with a passkey, not with a
Klonkt-login, so the paid gate now runs first; the fan gate stays as-is
for posts that are only fan_only.

Changed files:
src/routes/posts.js

  • paid-gate block moved above the fan-gate block, comment explains the order

-robo
Co-Authored-By: Claude Opus 4.8 <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/routes/posts.js

    r6cbd014 rd48ea02  
    12321232  }
    12331233
     1234  // Paid gate (klonkt-demo-aki): a paid post shows only a teaser to anyone who
     1235  // is not the owner/editor. Checked BEFORE the fan gate: a post that is both
     1236  // fan_only and paid unlocks with a passkey, not with a Klonkt-login, so the
     1237  // paid gate wins (otherwise anonymous visitors land on the login gate and
     1238  // never see the unlock button).
     1239  const canEditThis = req.session?.user && PermissionsService.canEditPost(req.session.user, post, site);
     1240  if (post.paid && !canEditThis) {
     1241    const { newerPost, olderPost } = postNeighbors(site, post, res.locals.tenancy === 'hub');
     1242    return renderPage(req, res, 'pages/paid-gate', {
     1243      pageTitle: post.title || 'Voor supporters',
     1244      bodyClass: 'on-special',
     1245      pgTitle: post.title || '',
     1246      pgTeaser: paidTeaser(post),
     1247      pgCents: post.paid_min_cents || paidDefaultMinCents(site.id),
     1248      pgSlug: post.slug,
     1249      newerPost,
     1250      olderPost,
     1251    });
     1252  }
     1253
    12341254  // Fan-only preview (premium #3): full content only for logged-in fans.
    12351255  // Anonymous visitors get a clean login gate instead of the content (the title/
     
    12441264      fgTitle: post.title || '',
    12451265      fgNext: (res.locals.siteUrlBase || '') + '/' + post.slug,
    1246       newerPost,
    1247       olderPost,
    1248     });
    1249   }
    1250 
    1251   // Paid gate (klonkt-demo-aki): a paid post shows only a teaser to anyone who
    1252   // is not the owner/editor. The passkey unlock arrives in slices 3-4; for now
    1253   // the owner previews the full post, everyone else sees the teaser + notice.
    1254   const canEditThis = req.session?.user && PermissionsService.canEditPost(req.session.user, post, site);
    1255   if (post.paid && !canEditThis) {
    1256     const { newerPost, olderPost } = postNeighbors(site, post, res.locals.tenancy === 'hub');
    1257     return renderPage(req, res, 'pages/paid-gate', {
    1258       pageTitle: post.title || 'Voor supporters',
    1259       bodyClass: 'on-special',
    1260       pgTitle: post.title || '',
    1261       pgTeaser: paidTeaser(post),
    1262       pgCents: post.paid_min_cents || paidDefaultMinCents(site.id),
    1263       pgSlug: post.slug,
    12641266      newerPost,
    12651267      olderPost,
Note: See TracChangeset for help on using the changeset viewer.