diff --git a/fluxer_api/src/api/auth/AuthRegistration.ts b/fluxer_api/src/api/auth/AuthRegistration.ts index 402a5461f..3db6f5241 100644 --- a/fluxer_api/src/api/auth/AuthRegistration.ts +++ b/fluxer_api/src/api/auth/AuthRegistration.ts @@ -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, diff --git a/fluxer_api/src/api/auth/tests/Registration.test.ts b/fluxer_api/src/api/auth/tests/Registration.test.ts index 6b2068cc2..fa78c480e 100644 --- a/fluxer_api/src/api/auth/tests/Registration.test.ts +++ b/fluxer_api/src/api/auth/tests/Registration.test.ts @@ -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 () => {