Changeset 640b39c in Klonkt for src/server.js


Ignore:
Timestamp:
06/14/2026 04:25:27 PM (3 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
a64f642
Parents:
8cb1dc7
Message:

auth: read-only view accounts (view everything, modify nothing)

New users.readonly column + readonly in the session. Global guard in server.js
blocks every state-modifying method (POST/PUT/PATCH/DELETE) for read-only
accounts -> no comments, saves, settings, nothing. GET remains free, so they
can view everything (including admin panels). Sticky "read-only demo" banner in
the shell when such an account is logged in.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/server.js

    r8cb1dc7 r640b39c  
    164164});
    165165
     166// Read-only/kijk-accounts: alles bekijken mag, niets wijzigen. Blokkeert elke
     167// state-wijzigende methode (de login-POST zelf zet de sessie pas, dus die valt
     168// hier nog niet onder).
     169app.use((req, res, next) => {
     170  if (req.session?.user?.readonly && req.method !== 'GET' && req.method !== 'HEAD' && req.method !== 'OPTIONS') {
     171    return res.status(403).send('Demo-account: alleen-lezen — wijzigen is uitgeschakeld.');
     172  }
     173  next();
     174});
     175
    166176app.use('/auth', authRoutes);
    167177app.use('/account', accountRoutes);
Note: See TracChangeset for help on using the changeset viewer.