From 6917e01ed8c3021f1fe8cafa8737004eefa63e81 Mon Sep 17 00:00:00 2001 From: deepshekhardas Date: Wed, 11 Mar 2026 06:25:04 +0530 Subject: [PATCH] feat: OAuth independent registration --- app/Http/Controllers/OauthController.php | 3 +- app/Models/OauthSetting.php | 2 +- ...ration_enabled_to_oauth_settings_table.php | 28 +++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 database/migrations/2026_03_10_122340_add_is_registration_enabled_to_oauth_settings_table.php diff --git a/app/Http/Controllers/OauthController.php b/app/Http/Controllers/OauthController.php index 3a3f18c9c..789f5ab83 100644 --- a/app/Http/Controllers/OauthController.php +++ b/app/Http/Controllers/OauthController.php @@ -18,11 +18,12 @@ class OauthController extends Controller public function callback(string $provider) { try { + $oauth_setting = OauthSetting::where('provider', $provider)->first(); $oauthUser = get_socialite_provider($provider)->user(); $user = User::whereEmail($oauthUser->email)->first(); if (! $user) { $settings = instanceSettings(); - if (! $settings->is_registration_enabled) { + if (! $settings->is_registration_enabled && ! $oauth_setting->is_registration_enabled) { abort(403, 'Registration is disabled'); } diff --git a/app/Models/OauthSetting.php b/app/Models/OauthSetting.php index 08e08d85b..8c6dd8e23 100644 --- a/app/Models/OauthSetting.php +++ b/app/Models/OauthSetting.php @@ -11,7 +11,7 @@ class OauthSetting extends Model { use HasFactory; - protected $fillable = ['provider', 'client_id', 'client_secret', 'redirect_uri', 'tenant', 'base_url', 'enabled']; + protected $fillable = ['provider', 'client_id', 'client_secret', 'redirect_uri', 'tenant', 'base_url', 'enabled', 'is_registration_enabled']; protected function clientSecret(): Attribute { diff --git a/database/migrations/2026_03_10_122340_add_is_registration_enabled_to_oauth_settings_table.php b/database/migrations/2026_03_10_122340_add_is_registration_enabled_to_oauth_settings_table.php new file mode 100644 index 000000000..24b308841 --- /dev/null +++ b/database/migrations/2026_03_10_122340_add_is_registration_enabled_to_oauth_settings_table.php @@ -0,0 +1,28 @@ +boolean('is_registration_enabled')->default(false); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('oauth_settings', function (Blueprint $table) { + $table->dropColumn('is_registration_enabled'); + }); + } +};