From 3ec4bfe0a8a338b9cc5c47ce7eec0f0f1ce8e42b Mon Sep 17 00:00:00 2001 From: Tim Filler Date: Sat, 23 Sep 2023 23:47:13 +0200 Subject: [PATCH] cs fixes --- plugins/auth/install/oauth2_google.php | 8 ++++---- plugins/auth/install/oauth2_twitch.php | 6 +++--- .../lib/yform/trait_value_auth_oauth2_google.php | 12 +++++------- .../lib/yform/trait_value_auth_oauth2_twitch.php | 12 +++++------- .../auth/lib/yform/value/ycom_auth_oauth2_google.php | 8 ++------ .../auth/lib/yform/value/ycom_auth_oauth2_twitch.php | 8 ++------ .../bootstrap/value.ycom_auth_oauth2_google.tpl.php | 6 +++--- .../bootstrap/value.ycom_auth_oauth2_twitch.tpl.php | 6 +++--- 8 files changed, 27 insertions(+), 39 deletions(-) diff --git a/plugins/auth/install/oauth2_google.php b/plugins/auth/install/oauth2_google.php index 023534ea..d3bb6c8a 100644 --- a/plugins/auth/install/oauth2_google.php +++ b/plugins/auth/install/oauth2_google.php @@ -1,8 +1,8 @@ 'someJibberish', // Go to https://console.cloud.google.com/ and setup a project. Setup an OAuth consent screen and choose scopes - 'clientSecret' => 'moreJibbereish', // In your project at https://console.cloud.google.com/, click on "Credential" and then "Create credentials => OAuth client ID". Fill out, add return url, get ID and secret - 'redirectUri' => 'https://your-url.com/maybe-a-subpage/?rex_ycom_auth_mode=oauth2_google&rex_ycom_auth_func=code' // do not fill out first and wait for the login error message to fill it out - //'hostedDomain' => 'your-url.com', // optional; used to restrict access to users on your G Suite/Google Apps for Business accounts + 'clientId' => 'someJibberish', // Go to https://console.cloud.google.com/ and setup a project. Setup an OAuth consent screen and choose scopes + 'clientSecret' => 'moreJibbereish', // In your project at https://console.cloud.google.com/, click on "Credential" and then "Create credentials => OAuth client ID". Fill out, add return url, get ID and secret + 'redirectUri' => 'https://your-url.com/maybe-a-subpage/?rex_ycom_auth_mode=oauth2_google&rex_ycom_auth_func=code', // do not fill out first and wait for the login error message to fill it out + // 'hostedDomain' => 'your-url.com', // optional; used to restrict access to users on your G Suite/Google Apps for Business accounts ]; diff --git a/plugins/auth/install/oauth2_twitch.php b/plugins/auth/install/oauth2_twitch.php index 74757bcd..e38cdd07 100644 --- a/plugins/auth/install/oauth2_twitch.php +++ b/plugins/auth/install/oauth2_twitch.php @@ -3,6 +3,6 @@ $settings = [ 'clientId' => 'someJibberish', // Go to https://dev.twitch.tv/console/apps and create an app. The client ID from your app 'clientSecret' => 'moreJibbereish', // In your app at https://dev.twitch.tv/console/apps, click on "Manage" and then "New Secret". The client password from your app - 'redirectUri' => 'https://your-url.com/maybe-a-subpage/?rex_ycom_auth_mode=oauth2_twitch&rex_ycom_auth_func=code' // do not fill out first and wait for the login error message to fill it out - add it to your allowed domains in your app at https://dev.twitch.tv/console/apps - //'scope' => 'user:read:email,user:read:follows', -]; \ No newline at end of file + 'redirectUri' => 'https://your-url.com/maybe-a-subpage/?rex_ycom_auth_mode=oauth2_twitch&rex_ycom_auth_func=code', // do not fill out first and wait for the login error message to fill it out - add it to your allowed domains in your app at https://dev.twitch.tv/console/apps + // 'scope' => 'user:read:email,user:read:follows', +]; diff --git a/plugins/auth/lib/yform/trait_value_auth_oauth2_google.php b/plugins/auth/lib/yform/trait_value_auth_oauth2_google.php index fde25810..ae88e869 100644 --- a/plugins/auth/lib/yform/trait_value_auth_oauth2_google.php +++ b/plugins/auth/lib/yform/trait_value_auth_oauth2_google.php @@ -8,10 +8,10 @@ trait rex_yform_trait_value_auth_oauth2_google */ private function auth_loadSettings(): array { - $SettingFile = $this->auth_ClassKey.'.php'; + $SettingFile = $this->auth_ClassKey . '.php'; $SettingsPath = rex_addon::get('ycom')->getDataPath($SettingFile); if (!file_exists($SettingsPath)) { - throw new rex_exception($this->auth_ClassKey . '-Settings file not found ['.$SettingsPath.']'); + throw new rex_exception($this->auth_ClassKey . '-Settings file not found [' . $SettingsPath . ']'); } $settings = []; @@ -30,9 +30,9 @@ private function auth_getReturnTo(): string private function auth_FormOutput(string $url): void { if ($this->needsOutput()) { - $this->params['form_output'][$this->getId()] = $this->parse(['value.ycom_auth_' . $this->auth_ClassKey. '.tpl.php', 'value.ycom_auth_extern.tpl.php'], [ + $this->params['form_output'][$this->getId()] = $this->parse(['value.ycom_auth_' . $this->auth_ClassKey . '.tpl.php', 'value.ycom_auth_extern.tpl.php'], [ 'url' => $url, - 'name' => '{{ ' . $this->auth_ClassKey. '_auth }}', + 'name' => '{{ ' . $this->auth_ClassKey . '_auth }}', ]); } } @@ -52,16 +52,14 @@ private function auth_redirectToFailed(string $message = ''): string /** * @param array $Userdata - * @param string $returnTo * @throws rex_exception - * @return void */ private function auth_createOrUpdateYComUser(array $Userdata, string $returnTo): void { $defaultUserAttributes = []; if ('' != $this->getElement(4)) { if (null == $defaultUserAttributes = json_decode($this->getElement(4), true)) { - throw new rex_exception($this->auth_ClassKey . '-DefaultUserAttributes is not a json'.$this->getElement(4)); + throw new rex_exception($this->auth_ClassKey . '-DefaultUserAttributes is not a json' . $this->getElement(4)); } } diff --git a/plugins/auth/lib/yform/trait_value_auth_oauth2_twitch.php b/plugins/auth/lib/yform/trait_value_auth_oauth2_twitch.php index 10cbca49..c7d840d9 100644 --- a/plugins/auth/lib/yform/trait_value_auth_oauth2_twitch.php +++ b/plugins/auth/lib/yform/trait_value_auth_oauth2_twitch.php @@ -8,10 +8,10 @@ trait rex_yform_trait_value_auth_oauth2_twitch */ private function auth_loadSettings(): array { - $SettingFile = $this->auth_ClassKey.'.php'; + $SettingFile = $this->auth_ClassKey . '.php'; $SettingsPath = rex_addon::get('ycom')->getDataPath($SettingFile); if (!file_exists($SettingsPath)) { - throw new rex_exception($this->auth_ClassKey . '-Settings file not found ['.$SettingsPath.']'); + throw new rex_exception($this->auth_ClassKey . '-Settings file not found [' . $SettingsPath . ']'); } $settings = []; @@ -30,9 +30,9 @@ private function auth_getReturnTo(): string private function auth_FormOutput(string $url): void { if ($this->needsOutput()) { - $this->params['form_output'][$this->getId()] = $this->parse(['value.ycom_auth_' . $this->auth_ClassKey. '.tpl.php', 'value.ycom_auth_extern.tpl.php'], [ + $this->params['form_output'][$this->getId()] = $this->parse(['value.ycom_auth_' . $this->auth_ClassKey . '.tpl.php', 'value.ycom_auth_extern.tpl.php'], [ 'url' => $url, - 'name' => '{{ ' . $this->auth_ClassKey. '_auth }}', + 'name' => '{{ ' . $this->auth_ClassKey . '_auth }}', ]); } } @@ -52,16 +52,14 @@ private function auth_redirectToFailed(string $message = ''): string /** * @param array $Userdata - * @param string $returnTo * @throws rex_exception - * @return void */ private function auth_createOrUpdateYComUser(array $Userdata, string $returnTo): void { $defaultUserAttributes = []; if ('' != $this->getElement(4)) { if (null == $defaultUserAttributes = json_decode($this->getElement(4), true)) { - throw new rex_exception($this->auth_ClassKey . '-DefaultUserAttributes is not a json'.$this->getElement(4)); + throw new rex_exception($this->auth_ClassKey . '-DefaultUserAttributes is not a json' . $this->getElement(4)); } } diff --git a/plugins/auth/lib/yform/value/ycom_auth_oauth2_google.php b/plugins/auth/lib/yform/value/ycom_auth_oauth2_google.php index 352d95a5..28cd5fe9 100644 --- a/plugins/auth/lib/yform/value/ycom_auth_oauth2_google.php +++ b/plugins/auth/lib/yform/value/ycom_auth_oauth2_google.php @@ -19,14 +19,10 @@ class rex_yform_value_ycom_auth_oauth2_google extends rex_yform_value_abstract { use rex_yform_trait_value_auth_oauth2_google; - /** - * @var array|string[] - */ + /** @var array|string[] */ private array $auth_requestFunctions = ['init', 'code', 'state']; private bool $auth_directLink = false; - /** - * @var array|string[] - */ + /** @var array|string[] */ private array $auth_SessionVars = ['OAUTH2_oauth2state']; private string $auth_ClassKey = 'oauth2_google'; diff --git a/plugins/auth/lib/yform/value/ycom_auth_oauth2_twitch.php b/plugins/auth/lib/yform/value/ycom_auth_oauth2_twitch.php index 230b7722..1ae63c81 100644 --- a/plugins/auth/lib/yform/value/ycom_auth_oauth2_twitch.php +++ b/plugins/auth/lib/yform/value/ycom_auth_oauth2_twitch.php @@ -19,14 +19,10 @@ class rex_yform_value_ycom_auth_oauth2_twitch extends rex_yform_value_abstract { use rex_yform_trait_value_auth_oauth2_twitch; - /** - * @var array|string[] - */ + /** @var array|string[] */ private array $auth_requestFunctions = ['init', 'code', 'state']; private bool $auth_directLink = false; - /** - * @var array|string[] - */ + /** @var array|string[] */ private array $auth_SessionVars = ['OAUTH2_oauth2state']; private string $auth_ClassKey = 'oauth2_twitch'; diff --git a/plugins/auth/ytemplates/bootstrap/value.ycom_auth_oauth2_google.tpl.php b/plugins/auth/ytemplates/bootstrap/value.ycom_auth_oauth2_google.tpl.php index 8b64d548..541e687e 100644 --- a/plugins/auth/ytemplates/bootstrap/value.ycom_auth_oauth2_google.tpl.php +++ b/plugins/auth/ytemplates/bootstrap/value.ycom_auth_oauth2_google.tpl.php @@ -5,7 +5,7 @@ * @psalm-scope-this rex_yform_value_abstract */ -$url = $url ?? ''; -$name = $name ?? ''; +$url ??= ''; +$name ??= ''; -echo '' . $this->name . ''; \ No newline at end of file +echo '' . $this->name . ''; diff --git a/plugins/auth/ytemplates/bootstrap/value.ycom_auth_oauth2_twitch.tpl.php b/plugins/auth/ytemplates/bootstrap/value.ycom_auth_oauth2_twitch.tpl.php index 8b64d548..541e687e 100644 --- a/plugins/auth/ytemplates/bootstrap/value.ycom_auth_oauth2_twitch.tpl.php +++ b/plugins/auth/ytemplates/bootstrap/value.ycom_auth_oauth2_twitch.tpl.php @@ -5,7 +5,7 @@ * @psalm-scope-this rex_yform_value_abstract */ -$url = $url ?? ''; -$name = $name ?? ''; +$url ??= ''; +$name ??= ''; -echo '' . $this->name . ''; \ No newline at end of file +echo '' . $this->name . '';