{"record":{"id":"ec445e15183ad8fe","repo":"BookStackApp/BookStack","slug":"auth-registrations-disabled","errorCode":null,"errorMessage":"auth.registrations_disabled","messagePattern":"auth\\.registrations_disabled","errorType":"exception","errorClass":"UserRegistrationException","httpStatus":null,"severity":"error","filePath":"app/Access/RegistrationService.php","lineNumber":31,"sourceCode":"use Illuminate\\Support\\Str;\n\nclass RegistrationService\n{\n    public function __construct(\n        protected UserRepo $userRepo,\n        protected EmailConfirmationService $emailConfirmationService,\n    ) {\n    }\n\n    /**\n     * Check if registrations are allowed in the app settings.\n     *\n     * @throws UserRegistrationException\n     */\n    public function ensureRegistrationAllowed()\n    {\n        if (!$this->registrationAllowed()) {\n            throw new UserRegistrationException(trans('auth.registrations_disabled'), '/login');\n        }\n    }\n\n    /**\n     * Check if standard BookStack User registrations are currently allowed.\n     * Does not prevent external-auth based registration.\n     */\n    protected function registrationAllowed(): bool\n    {\n        $authMethod = config('auth.method');\n        $authMethodsWithRegistration = ['standard'];\n\n        return in_array($authMethod, $authMethodsWithRegistration) && setting('registration-enabled');\n    }\n\n    /**\n     * Attempt to find a user in the system otherwise register them as a new\n     * user. For use with external auth systems since password is auto-generated.","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/BookStackApp/BookStack/blob/18f8469a1c72f8cc8497e9372635e6dea5028071/app/Access/RegistrationService.php#L13-L49","documentation":"RegistrationService::ensureRegistrationAllowed() throws UserRegistrationException with the translated 'auth.registrations_disabled' message when standard (non-external) user registration is not permitted. It guards flows that attempt to create a new local account while REGISTRATION_ENABLED is false.","triggerScenarios":"ensureRegistrationAllowed() is called and $this->registrationAllowed() returns false — i.e. the 'registration_enabled' setting is off — during a standard sign-up or a registration path that does not come from a configured external auth system.","commonSituations":"New users clicking 'Sign up' after an admin disabled registration; self-hosted instances with REGISTRATION_ENABLED=false in .env; users whose OIDC/SAML match fails and code falls back to a standard registration path.","solutions":["If self-registration should work, enable it: set REGISTRATION_ENABLED=true in .env and clear caches (php artisan cache:clear)","If registration should stay closed, direct users to their auth provider (OIDC/SAML/LDAP) so they are matched to existing accounts","Admins can create accounts manually via the Users admin page","Check that the external auth config is correct so external logins are treated as external (bypassing this check) rather than standard registration"],"exampleFix":"// before (.env)\nREGISTRATION_ENABLED=false\n// after\nREGISTRATION_ENABLED=true","handlingStrategy":"validation","validationCode":"// Check before exposing sign-up UI or calling the flow:\n$enabled = env('REGISTRATION_ENABLED', false);\nif (!$enabled) {\n    // hide registration links; route users to OIDC/SAML/LDAP login instead\n}","typeGuard":null,"tryCatchPattern":"try {\n    $service->ensureRegistrationAllowed();\n} catch (BookStack\\Access\\UserRegistrationException $e) {\n    if (trans('auth.registrations_disabled') === $e->getMessage()) {\n        return redirect('/login')->withErrors(['registration' => 'Sign-ups are disabled; use your identity provider or contact an admin']);\n    }\n    throw $e;\n}","preventionTips":["Set REGISTRATION_ENABLED=true if self-signup is intended","Hide registration UI when registration is disabled","Create accounts manually via admin for closed instances","Use external auth (OIDC/SAML/LDAP) for provisioning closed instances"],"tags":["registration","configuration"],"backgroundTag":"registration-disabled","analyzedSha":"18f8469a1c72f8cc8497e9372635e6dea5028071","analyzedAt":"2026-09-02T19:49:33.068Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}