Skip to content

Commit

Permalink
cs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
elricco committed Sep 23, 2023
1 parent 09ee2c4 commit 3ec4bfe
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 39 deletions.
8 changes: 4 additions & 4 deletions plugins/auth/install/oauth2_google.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

$settings = [
'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
'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
];
6 changes: 3 additions & 3 deletions plugins/auth/install/oauth2_twitch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
];
'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',
];
12 changes: 5 additions & 7 deletions plugins/auth/lib/yform/trait_value_auth_oauth2_google.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -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 }}',
]);
}
}
Expand All @@ -52,16 +52,14 @@ private function auth_redirectToFailed(string $message = ''): string

/**
* @param array<int|string, mixed> $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));
}
}

Expand Down
12 changes: 5 additions & 7 deletions plugins/auth/lib/yform/trait_value_auth_oauth2_twitch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -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 }}',
]);
}
}
Expand All @@ -52,16 +52,14 @@ private function auth_redirectToFailed(string $message = ''): string

/**
* @param array<int|string, mixed> $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));
}
}

Expand Down
8 changes: 2 additions & 6 deletions plugins/auth/lib/yform/value/ycom_auth_oauth2_google.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
8 changes: 2 additions & 6 deletions plugins/auth/lib/yform/value/ycom_auth_oauth2_twitch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @psalm-scope-this rex_yform_value_abstract
*/

$url = $url ?? '';
$name = $name ?? '';
$url ??= '';
$name ??= '';

echo '<a class="'. $this->name .'" href="'.$url.'">' . $this->name . '</a>';
echo '<a class="' . $this->name . '" href="' . $url . '">' . $this->name . '</a>';
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @psalm-scope-this rex_yform_value_abstract
*/

$url = $url ?? '';
$name = $name ?? '';
$url ??= '';
$name ??= '';

echo '<a class="'. $this->name .'" href="'.$url.'">' . $this->name . '</a>';
echo '<a class="' . $this->name . '" href="' . $url . '">' . $this->name . '</a>';

0 comments on commit 3ec4bfe

Please sign in to comment.