mirror of
https://github.com/coollabsio/coolify.git
synced 2026-03-11 08:55:47 +00:00
Merge d6c30570ab into 201998638a
This commit is contained in:
commit
b8f7c15710
4 changed files with 49 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ use Livewire\Component;
|
|||
class SettingsOauth extends Component
|
||||
{
|
||||
public $oauth_settings_map;
|
||||
public $oauth_auto_redirect;
|
||||
|
||||
protected function rules()
|
||||
{
|
||||
|
|
@ -28,6 +29,7 @@ class SettingsOauth extends Component
|
|||
if (! isInstanceAdmin()) {
|
||||
return redirect()->route('home');
|
||||
}
|
||||
$this->oauth_auto_redirect = instanceSettings()->oauth_auto_redirect;
|
||||
$this->oauth_settings_map = OauthSetting::all()->sortBy('provider')->reduce(function ($carry, $setting) {
|
||||
$carry[$setting->provider] = [
|
||||
'id' => $setting->id,
|
||||
|
|
@ -83,6 +85,9 @@ class SettingsOauth extends Component
|
|||
|
||||
$this->dispatch('success', 'OAuth settings for '.$oauth->provider.' updated successfully!');
|
||||
} else {
|
||||
$settings = instanceSettings();
|
||||
$settings->update(['oauth_auto_redirect' => $this->oauth_auto_redirect]);
|
||||
|
||||
$errors = [];
|
||||
foreach (array_values($this->oauth_settings_map) as $settingData) {
|
||||
$oauth = OauthSetting::find($settingData['id']);
|
||||
|
|
|
|||
|
|
@ -60,6 +60,11 @@ class FortifyServiceProvider extends ServiceProvider
|
|||
$settings = instanceSettings();
|
||||
$enabled_oauth_providers = OauthSetting::where('enabled', true)->get();
|
||||
$users = User::count();
|
||||
|
||||
if (!request()->has('skip_oauth') && $settings->oauth_auto_redirect && $enabled_oauth_providers->where('provider', $settings->oauth_auto_redirect)->isNotEmpty()) {
|
||||
return redirect()->route('auth.redirect', ['provider' => $settings->oauth_auto_redirect]);
|
||||
}
|
||||
|
||||
if ($users == 0) {
|
||||
// If there are no users, redirect to registration
|
||||
return redirect()->route('register');
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('instance_settings', function (Blueprint $table) {
|
||||
$table->string('oauth_auto_redirect')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('instance_settings', function (Blueprint $table) {
|
||||
$table->dropColumn('oauth_auto_redirect');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -13,6 +13,17 @@
|
|||
</div>
|
||||
<div class="pb-4 ">Custom authentication (OAuth) configurations.</div>
|
||||
</div>
|
||||
<div class="mb-5 w-96">
|
||||
<x-forms.select label="Forced OAuth Login" id="oauth_auto_redirect" helper="If selected, users will be automatically redirected to this provider when visiting the login page.<br>To bypass this, use <code>/login?skip_oauth</code>.">
|
||||
<option value="">None</option>
|
||||
@foreach ($oauth_settings_map as $oauth_setting)
|
||||
@if ($oauth_setting['enabled'])
|
||||
<option value="{{ $oauth_setting['provider'] }}">{{ ucfirst($oauth_setting['provider']) }}
|
||||
</option>
|
||||
@endif
|
||||
@endforeach
|
||||
</x-forms.select>
|
||||
</div>
|
||||
<div class="flex flex-col gap-2 pt-4">
|
||||
@foreach ($oauth_settings_map as $oauth_setting)
|
||||
<div class="p-4 border dark:border-coolgray-300 border-neutral-200">
|
||||
|
|
|
|||
Loading…
Reference in a new issue