From 661dc4e65405f2e1a3f2b1fc0e2f8fc05ad2847c Mon Sep 17 00:00:00 2001 From: Terncode Date: Wed, 18 Nov 2026 18:22:44 +0100 Subject: [PATCH] Check age when joining 18+ servers --- src/ts/server/api/game.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ts/server/api/game.ts b/src/ts/server/api/game.ts index 552ee96..0bd5da8 100644 --- a/src/ts/server/api/game.ts +++ b/src/ts/server/api/game.ts @@ -4,7 +4,8 @@ import { UserError } from '../userError'; import { InternalGameServerState } from '../../common/adminInterfaces'; import { JoinResponse } from '../../common/interfaces'; import { meetsRequirement } from '../../common/accountUtils'; -import { supporterLevel } from '../../common/adminUtils'; +import { supporterLevel, getAge } from '../../common/adminUtils'; +import { MIN_ADULT_AGE } from '../../common/constants'; import { isServerOffline } from '../serverUtils'; import { getAccountAlertMessage } from '../accountUtils'; @@ -63,6 +64,10 @@ export const createJoinGame = throw new UserError('Server is restricted'); } + if (server.state.alert === '18+' && !(account.birthdate && getAge(account.birthdate) >= MIN_ADULT_AGE)) { + throw new UserError('Server is restricted'); + } + if (!characterId || typeof characterId !== 'string') { throw new UserError('Invalid data', { message: 'Invalid pony ID', desc: `"${characterId}"` }); }