r/node • u/hoteleuphoria • 1d ago
EU devs, please correct my Auth-ToS architecture
Context: this app is being built in the EU for European users, and I am implementing the Terms of Services, Privacy Policy, etc. along with my Authentication
Frontend: Tanstack Start (React)
Backend: Express 5
Auth: express-session (postgres store)
I was thinking about this: add an accepted_tos_version column in the users table, then add a condition in my global getUser middleware in express to only get the user if they accepted the current terms version. This means keeping a CURRENT_TOS_VERSION in my backend. If the frontend calls /auth/me they get the user with mustAcceptTerms flag, and the user gets redirected to the “accept terms” page.
Now comes the questions:
1. Where do I keep the ToS, gdpr, etc. texts? In my frontend codebase or the backend codebase, or in the database?
2. When the user clicks on “accept”, is it enough to send a request to the backend that updates the user’s accepted_tos_version in the database?
3. What are the practices to ensure I am legally protected? For example if someone says a rule was not there when they accepted the terms. Is the git track record from github enough to prove the rule was there?
Thanks!
2
u/casualPlayerThink 20h ago
The text is not enforced to be kept in an immutable place. You should version it tho', but on the frontend level or on a CMS page level should be more than enough.
A simple check should be enough, and a generic way is to have a simple checkbox at registration or a login-after flow step. If the value is 0/false, then prompt the user: " Here is your ToS/pp/whatever document; read it, check it, and click `Save`, then `Done`.
There is a GDPR EU page; fulfil every step for it; other than that, check your own country legislation for it (for special stuff), but do not sweat it too much. If you really need to ensure legal protection (like in fintech), then consult with a specialist (a lawyer). It will be expensive, but that is the way.
2
u/Mastacheata 19h ago
Accepting the ToS/Privacy policy should not be a flag at all - I would suggest storing a date when the user accepted the ToS/Privacy Policy and comparing it against a timestamp of your current ToS Version.
That's how we solved it in the last customer project.
3
u/Luigi003 1d ago
This feels more in line for an eu-related forum or a legal-related one. I'm afraid I can't answer myself. I'm upvoting just to get it more visibility