mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 12:14:45 +02:00
Cleanup OAuth
_noenv & enabled providers (#989)
This commit is contained in:
parent
a6963ad802
commit
35d25d216e
@ -31,8 +31,9 @@ final class DiscordProvider extends OAuthProvider
|
||||
->content(new HtmlString('<p>Visit the <u><a href="https://discord.com/developers/applications" target="_blank">Discord Developer Portal</a></u> and click on <b>New Application</b>. Enter a <b>Name</b> (e.g. your panel name) and click on <b>Create</b>.</p><p>Copy the <b>Client ID</b> and the <b>Client Secret</b>, you will need them in the final step.</p>')),
|
||||
Placeholder::make('')
|
||||
->content(new HtmlString('<p>Under <b>Redirects</b> add the below URL.</p>')),
|
||||
TextInput::make('_noenv_redirect')
|
||||
TextInput::make('_noenv_callback')
|
||||
->label('Redirect URL')
|
||||
->dehydrated()
|
||||
->disabled()
|
||||
->hintAction(fn () => request()->isSecure() ? CopyAction::make() : null)
|
||||
->formatStateUsing(fn () => config('app.url') . (Str::endsWith(config('app.url'), '/') ? '' : '/') . 'auth/oauth/callback/discord'),
|
||||
|
@ -25,6 +25,7 @@ final class GithubProvider extends OAuthProvider
|
||||
->content(new HtmlString('<p>Visit the <u><a href="https://github.com/settings/developers" target="_blank">Github Developer Dashboard</a></u>, go to <b>OAuth Apps</b> and click on <b>New OAuth App</b>.</p><p>Enter an <b>Application name</b> (e.g. your panel name), set <b>Homepage URL</b> to your panel url and enter the below url as <b>Authorization callback URL</b>.</p>')),
|
||||
TextInput::make('_noenv_callback')
|
||||
->label('Authorization callback URL')
|
||||
->dehydrated()
|
||||
->disabled()
|
||||
->hintAction(fn () => request()->isSecure() ? CopyAction::make() : null)
|
||||
->default(fn () => config('app.url') . (Str::endsWith(config('app.url'), '/') ? '' : '/') . 'auth/oauth/callback/github'),
|
||||
|
@ -513,8 +513,6 @@ class Settings extends Page implements HasForms
|
||||
"OAUTH_{$id}_ENABLED" => 'true',
|
||||
], $data);
|
||||
|
||||
$data = array_filter($data, fn ($value) => !Str::startsWith($value, '_noenv'));
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$set($key, $value);
|
||||
}
|
||||
|
@ -61,6 +61,8 @@ class EditProfile extends BaseEditProfile
|
||||
|
||||
protected function getForms(): array
|
||||
{
|
||||
$oauthProviders = collect(OAuthProvider::get())->filter(fn (OAuthProvider $provider) => $provider->isEnabled())->all();
|
||||
|
||||
return [
|
||||
'form' => $this->form(
|
||||
$this->makeForm()
|
||||
@ -122,24 +124,11 @@ class EditProfile extends BaseEditProfile
|
||||
|
||||
Tab::make(trans('profile.tabs.oauth'))
|
||||
->icon('tabler-brand-oauth')
|
||||
->visible(function () {
|
||||
$oauthProviders = OAuthProvider::get();
|
||||
foreach ($oauthProviders as $oauthProvider) {
|
||||
if ($oauthProvider->isEnabled()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
})
|
||||
->schema(function () {
|
||||
->visible(count($oauthProviders) > 0)
|
||||
->schema(function () use ($oauthProviders) {
|
||||
$actions = [];
|
||||
|
||||
$oauthProviders = OAuthProvider::get();
|
||||
foreach ($oauthProviders as $oauthProvider) {
|
||||
if (!$oauthProvider->isEnabled()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$id = $oauthProvider->getId();
|
||||
$name = $oauthProvider->getName();
|
||||
|
@ -58,11 +58,9 @@ class Login extends BaseLogin
|
||||
{
|
||||
$actions = [];
|
||||
|
||||
$oauthProviders = OAuthProvider::get();
|
||||
$oauthProviders = collect(OAuthProvider::get())->filter(fn (OAuthProvider $provider) => $provider->isEnabled())->all();
|
||||
|
||||
foreach ($oauthProviders as $oauthProvider) {
|
||||
if (!$oauthProvider->isEnabled()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$id = $oauthProvider->getId();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user