mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 00:43:15 +00:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user