fix(auth): stop flagging dev instance signups as staff (#3469)

This commit is contained in:
Hampus authored and GitHub committed 2026-10-14 17:09:14 +02:00
1 parent d2f19660e5
commit 8c05497c37
2 files changed
+16 -3

No files matched your search

+2 -3
View File
@@ -52,7 +52,7 @@ import {inputValidationErrorFromZodIssues} from '@app/api/Validator';
import {AccountIdentityModes, TagStyles} from '@fluxer/constants/src/AccountIdentityConstants';
import {AdminACLs} from '@fluxer/constants/src/AdminACLs';
import {getRegionalMinimumAge} from '@fluxer/constants/src/RegionalMinimumAge';
import {ProfileFieldPrivacyFlags, UserFlags} from '@fluxer/constants/src/UserConstants';
import {ProfileFieldPrivacyFlags} from '@fluxer/constants/src/UserConstants';
import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes';
import {RegistrationClosedError} from '@fluxer/errors/src/domains/auth/RegistrationClosedError';
import {RegistrationCredentialsRequiredError} from '@fluxer/errors/src/domains/auth/RegistrationCredentialsRequiredError';
@@ -257,7 +257,6 @@ async function registerAccount(
const acceptLanguage = request.headers.get('accept-language');
const userLocale = parseAcceptLanguage(acceptLanguage);
const passwordHash = data.password ? await hashPassword(data.password) : null;
const flags = config.nodeEnv === 'development' ? UserFlags.STAFF : 0n;
const userRow: UserRow = {
...EMPTY_USER_ROW,
user_id: userId,
@@ -275,7 +274,7 @@ async function registerAccount(
timezone_privacy_flags: ProfileFieldPrivacyFlags.EVERYONE,
date_of_birth: dateOfBirth,
locale: userLocale,
flags,
flags: 0n,
terms_agreed_at: requiresTermsConsent ? now : null,
privacy_agreed_at: requiresPrivacyConsent ? now : null,
last_active_at: now,
@@ -23,6 +23,7 @@ import type {ApiTestHarness} from '@app/api/test/ApiTestHarness';
import {HTTP_STATUS} from '@app/api/test/TestConstants';
import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder';
import {AdminACLs} from '@fluxer/constants/src/AdminACLs';
import {UserFlags} from '@fluxer/constants/src/UserConstants';
import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes';
import {getSameIpDecisionKey} from '@fluxer/ip_utils/src/IpAddress';
import {ms} from 'itty-time';
@@ -126,6 +127,19 @@ describe('Auth registration', () => {
expect(reg.user_id.length).toBeGreaterThan(0);
expect(Object.keys(reg).sort()).toEqual(['token', 'user', 'user_id']);
});
it('does not flag accounts registered on a development instance as staff', async () => {
expect(getConfig().nodeEnv).toBe('development');
const reg = await registerUser(harness, {
email: createUniqueEmail('devnotstaff'),
username: createUniqueUsername('devnotstaff'),
global_name: 'Dev User',
password: 'a-strong-password',
date_of_birth: '2000-01-01',
consent: true,
});
const user = await getUserRepository().findUniqueAssert(createUserID(BigInt(reg.user_id)));
expect(user.flags & UserFlags.STAFF).toBe(0n);
});
it('grants wildcard admin ACL to first accepted local dev registration', async () => {
await getInstanceConfigRepository().updateCaptchaConfig({enabled: false});
await withBootstrapAdminConfig({selfHosted: false, testModeEnabled: false}, async () => {