diff options
| author | 2024-08-01 20:31:40 +0200 | |
|---|---|---|
| committer | 2024-08-01 20:31:40 +0200 | |
| commit | d2247221bbf23a8fe19f66ea4ad7d0a59ffaa5b4 (patch) | |
| tree | f5174c1b1d174cd41dca20f350e1297894e1c6fa /app/Models/Auth.php | |
| parent | b2c8cb74562b2f7cb290abd61ff1b6f35475f23a (diff) | |
Minor update whitespace PHPCS rules (#6666)
* Minor update whitespace PHPCS rules
To simplify our configuration, apply more rules, and be clearer about what is added or removed compared with PSR12.
Does not change our current conventions, but just a bit more consistent.
* Forgotten *.phtml
* Sort exclusion patterns + add a few for Extensions repo
* Relaxed some rules
Diffstat (limited to 'app/Models/Auth.php')
| -rw-r--r-- | app/Models/Auth.php | 130 |
1 files changed, 65 insertions, 65 deletions
diff --git a/app/Models/Auth.php b/app/Models/Auth.php index 416f3061d..f65a59e03 100644 --- a/app/Models/Auth.php +++ b/app/Models/Auth.php @@ -54,48 +54,48 @@ class FreshRSS_Auth { private static function accessControl(): bool { $auth_type = FreshRSS_Context::systemConf()->auth_type; switch ($auth_type) { - case 'form': - $credentials = FreshRSS_FormAuth::getCredentialsFromCookie(); - $current_user = ''; - if (isset($credentials[1])) { - $current_user = trim($credentials[0]); - Minz_Session::_params([ + case 'form': + $credentials = FreshRSS_FormAuth::getCredentialsFromCookie(); + $current_user = ''; + if (isset($credentials[1])) { + $current_user = trim($credentials[0]); + Minz_Session::_params([ Minz_User::CURRENT_USER => $current_user, 'passwordHash' => trim($credentials[1]), 'csrf' => false, - ]); - } - return $current_user != ''; - case 'http_auth': - $current_user = httpAuthUser(); - if ($current_user == '') { - return false; - } - $login_ok = FreshRSS_UserDAO::exists($current_user); - if (!$login_ok && FreshRSS_Context::systemConf()->http_auth_auto_register) { - $email = null; - if (FreshRSS_Context::systemConf()->http_auth_auto_register_email_field !== '' && - isset($_SERVER[FreshRSS_Context::systemConf()->http_auth_auto_register_email_field])) { - $email = (string)$_SERVER[FreshRSS_Context::systemConf()->http_auth_auto_register_email_field]; + ]); } - $language = Minz_Translate::getLanguage(null, Minz_Request::getPreferredLanguages(), FreshRSS_Context::systemConf()->language); - Minz_Translate::init($language); - $login_ok = FreshRSS_user_Controller::createUser($current_user, $email, '', [ + return $current_user != ''; + case 'http_auth': + $current_user = httpAuthUser(); + if ($current_user == '') { + return false; + } + $login_ok = FreshRSS_UserDAO::exists($current_user); + if (!$login_ok && FreshRSS_Context::systemConf()->http_auth_auto_register) { + $email = null; + if (FreshRSS_Context::systemConf()->http_auth_auto_register_email_field !== '' && + isset($_SERVER[FreshRSS_Context::systemConf()->http_auth_auto_register_email_field])) { + $email = (string)$_SERVER[FreshRSS_Context::systemConf()->http_auth_auto_register_email_field]; + } + $language = Minz_Translate::getLanguage(null, Minz_Request::getPreferredLanguages(), FreshRSS_Context::systemConf()->language); + Minz_Translate::init($language); + $login_ok = FreshRSS_user_Controller::createUser($current_user, $email, '', [ 'language' => $language, - ]); - } - if ($login_ok) { - Minz_Session::_params([ + ]); + } + if ($login_ok) { + Minz_Session::_params([ Minz_User::CURRENT_USER => $current_user, 'csrf' => false, - ]); - } - return $login_ok; - case 'none': - return true; - default: - // TODO load extension - return false; + ]); + } + return $login_ok; + case 'none': + return true; + default: + // TODO load extension + return false; } } @@ -110,19 +110,19 @@ class FreshRSS_Auth { } switch (FreshRSS_Context::systemConf()->auth_type) { - case 'form': - self::$login_ok = Minz_Session::paramString('passwordHash') === FreshRSS_Context::userConf()->passwordHash; - break; - case 'http_auth': - $current_user = Minz_User::name() ?? ''; - self::$login_ok = strcasecmp($current_user, httpAuthUser()) === 0; - break; - case 'none': - self::$login_ok = true; - break; - default: - // TODO: extensions - self::$login_ok = false; + case 'form': + self::$login_ok = Minz_Session::paramString('passwordHash') === FreshRSS_Context::userConf()->passwordHash; + break; + case 'http_auth': + $current_user = Minz_User::name() ?? ''; + self::$login_ok = strcasecmp($current_user, httpAuthUser()) === 0; + break; + case 'none': + self::$login_ok = true; + break; + default: + // TODO: extensions + self::$login_ok = false; } Minz_Session::_params([ @@ -147,13 +147,13 @@ class FreshRSS_Auth { $default_user = FreshRSS_Context::systemConf()->default_user; $ok = self::$login_ok; switch ($scope) { - case 'general': - break; - case 'admin': - $ok &= $default_user === $currentUser || $isAdmin; - break; - default: - $ok = false; + case 'general': + break; + case 'admin': + $ok &= $default_user === $currentUser || $isAdmin; + break; + default: + $ok = false; } return (bool)$ok; } @@ -186,16 +186,16 @@ class FreshRSS_Auth { Minz_User::change($username); switch (FreshRSS_Context::systemConf()->auth_type) { - case 'form': - Minz_Session::_param('passwordHash'); - FreshRSS_FormAuth::deleteCookie(); - break; - case 'http_auth': - case 'none': - // Nothing to do… - break; - default: - // TODO: extensions + case 'form': + Minz_Session::_param('passwordHash'); + FreshRSS_FormAuth::deleteCookie(); + break; + case 'http_auth': + case 'none': + // Nothing to do… + break; + default: + // TODO: extensions } } |
