Skip to content

Commit f7e10aa

Browse files
bobbyonmagicbobbyiliev
authored andcommitted
fix: Block social sign-on registration when registrations are disabled
When registration_enabled is set to false, new users could still create accounts via social sign-on (Google, Facebook, etc.). This fix adds a check in SocialController::findOrCreateProviderUser() to reject new user creation when registrations are disabled, while still allowing existing users to log in via social providers.
1 parent 779cd91 commit f7e10aa

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Http/Controllers/SocialController.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ private function findOrCreateProviderUser($socialiteUser, $driver)
7777

7878
$user = app(config('auth.providers.users.model'))->where('email', $socialiteUser->getEmail())->first();
7979

80+
// If no existing user and registrations are disabled, reject the request
81+
if (! $user && ! config('devdojo.auth.settings.registration_enabled', true)) {
82+
return redirect()->route('auth.login')->with('error',
83+
config('devdojo.auth.language.register.registrations_disabled', 'Registrations are currently disabled.'));
84+
}
85+
8086
if ($user) {
8187
$existingProvider = $user->socialProviders()->first();
8288
if ($existingProvider) {

0 commit comments

Comments
 (0)