/
dimamir
/
coolify
Обзор
Документация
Войти
/
dimamir
/
coolify
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
app/Livewire/SettingsOauth.php
54 строки
1 KB
Andras Bacsai
Refactor license and OAuth settings to redirect non-admin users to home page
24 окт 2024, 21:49
24 окт 2024, 21:49
25b0c8e
Код
Авторство
О чём код?
<?php namespace App\Livewire; use App\Models\OauthSetting; use Livewire\Component; class SettingsOauth extends Component { public $oauth_settings_map; protected function rules() { return OauthSetting::all()->reduce(function ($carry, $setting) { $carry["oauth_settings_map.$setting->provider.enabled"] = 'required'; $carry["oauth_settings_map.$setting->provider.client_id"] = 'nullable'; $carry["oauth_settings_map.$setting->provider.client_secret"] = 'nullable'; $carry["oauth_settings_map.$setting->provider.redirect_uri"] = 'nullable'; $carry["oauth_settings_map.$setting->provider.tenant"] = 'nullable'; return $carry; }, []); } public function mount() { if (! isInstanceAdmin()) { return redirect()->route('home'); } $this->oauth_settings_map = OauthSetting::all()->sortBy('provider')->reduce(function ($carry, $setting) { $carry[$setting->provider] = $setting; return $carry; }, []); } private function updateOauthSettings() { foreach (array_values($this->oauth_settings_map) as &$setting) { $setting->save(); } } public function instantSave() { $this->updateOauthSettings(); } public function submit() { $this->updateOauthSettings(); $this->dispatch('success', 'Instance settings updated successfully!'); } }