Changeset e9229f2 in Klonkt


Ignore:
Timestamp:
06/16/2026 06:45:02 PM (3 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
1be21ba
Parents:
029f047
Message:

Phase 4: Fan login (Google) behind premium gate

fanLoginReady() = googleConfigured() && premiumUnlocked(). The "Sign in
with Google" button, /auth/google-start, and the callback are now gated on
this (premium off = freely available, demos unchanged; on = Patreon
required).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/routes/auth.js

    r029f047 re9229f2  
    88import { safeNext } from '../middleware/auth.js';
    99import { googleConfigured, authorizeUrl, exchangeCode, fetchUserinfo } from '../config/google.js';
     10import { premiumUnlocked } from '../services/PatreonService.js';
     11
     12// Fan-login (luisteraars inloggen met Google om te reageren) is een premium-
     13// feature: beschikbaar als Google is ingesteld ÉN de premium-laag ontgrendeld is
     14// (premium uit = vrij; aan = Patreon vereist).
     15function fanLoginReady() {
     16  return googleConfigured() && premiumUnlocked();
     17}
    1018import { mailerConfigured, sendMail } from '../config/mailer.js';
    1119
     
    4755    success: req.query.success || null,
    4856    username: '',
    49     googleReady: googleConfigured(),
     57    googleReady: fanLoginReady(),
    5058    next,
    5159  });
     
    6068    return renderPage(req, res, 'pages/auth-login', {
    6169      pageTitle: 'Inloggen', bodyClass: 'on-special',
    62       error, success: null, username: username || '', googleReady: googleConfigured(), next,
     70      error, success: null, username: username || '', googleReady: fanLoginReady(), next,
    6371    });
    6472  };
     
    226234// Per-instance, eigen Google-client. Geeft ALTIJD rol member — nooit beheer.
    227235router.get('/google', (req, res) => {
    228   if (!googleConfigured()) {
    229     return res.redirect('/auth/login?error=' + encodeURIComponent('Google-login is op deze site niet ingesteld.'));
     236  if (!fanLoginReady()) {
     237    return res.redirect('/auth/login?error=' + encodeURIComponent('Inloggen met Google is op deze site niet beschikbaar.'));
    230238  }
    231239  const state = crypto.randomBytes(16).toString('hex');
     
    248256router.get('/google/callback', async (req, res) => {
    249257  const fail = (msg) => res.redirect('/auth/login?error=' + encodeURIComponent(msg));
     258  if (!fanLoginReady()) return fail('Inloggen met Google is op deze site niet beschikbaar.');
    250259  try {
    251260    const { code, state } = req.query;
Note: See TracChangeset for help on using the changeset viewer.