fix(auth): honor password registration policy during setup

Apply the resolved authentication toggles before creating a password account. Keep setup and invitations available when password sign-in permits them.
This commit is contained in:
Maurice
2026-11-30 22:10:19 +01:00
parent 4d3f7fd355
commit c0b28dd4da
2 changed files with 29 additions and 5 deletions
+5 -5
View File
@@ -427,11 +427,11 @@ export class AuthService {
if (validInvite.expires_at && new Date(validInvite.expires_at) < new Date()) throw new DomainError(410, 'Invite link has expired');
}
if (userCount > 0 && !validInvite) {
const toggles = await this.resolveAuthToggles();
if (!toggles.password_registration) {
throw new DomainError(403, 'Password registration is disabled. Contact your administrator.');
}
const toggles = await this.resolveAuthToggles();
// Setup and invitations still use the password sign-in policy.
const canUseClosedRegistration = toggles.password_login && (userCount === 0 || validInvite !== null);
if (!toggles.password_registration && !canUseClosedRegistration) {
throw new DomainError(403, 'Password registration is disabled. Contact your administrator.');
}
if (!username || !email || !password) {