summaryrefslogtreecommitdiff
path: root/app/Models/Auth.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Models/Auth.php')
-rw-r--r--app/Models/Auth.php38
1 files changed, 19 insertions, 19 deletions
diff --git a/app/Models/Auth.php b/app/Models/Auth.php
index e5f7fc0b9..c66bb5016 100644
--- a/app/Models/Auth.php
+++ b/app/Models/Auth.php
@@ -24,7 +24,7 @@ class FreshRSS_Auth {
self::$login_ok = Minz_Session::paramBoolean('loginOk');
$current_user = Minz_User::name();
if ($current_user === null) {
- $current_user = FreshRSS_Context::$system_conf->default_user;
+ $current_user = FreshRSS_Context::systemConf()->default_user;
Minz_Session::_params([
Minz_User::CURRENT_USER => $current_user,
'csrf' => false,
@@ -51,7 +51,7 @@ class FreshRSS_Auth {
* @return bool true if user can be connected, false otherwise.
*/
private static function accessControl(): bool {
- $auth_type = FreshRSS_Context::$system_conf->auth_type;
+ $auth_type = FreshRSS_Context::systemConf()->auth_type;
switch ($auth_type) {
case 'form':
$credentials = FreshRSS_FormAuth::getCredentialsFromCookie();
@@ -71,13 +71,13 @@ class FreshRSS_Auth {
return false;
}
$login_ok = FreshRSS_UserDAO::exists($current_user);
- if (!$login_ok && FreshRSS_Context::$system_conf->http_auth_auto_register) {
+ if (!$login_ok && FreshRSS_Context::systemConf()->http_auth_auto_register) {
$email = null;
- if (FreshRSS_Context::$system_conf->http_auth_auto_register_email_field !== '' &&
- isset($_SERVER[FreshRSS_Context::$system_conf->http_auth_auto_register_email_field])) {
- $email = (string)$_SERVER[FreshRSS_Context::$system_conf->http_auth_auto_register_email_field];
+ 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::$system_conf->language);
+ $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,
@@ -103,17 +103,17 @@ class FreshRSS_Auth {
*/
public static function giveAccess(): bool {
FreshRSS_Context::initUser();
- if (FreshRSS_Context::$user_conf == null) {
+ if (!FreshRSS_Context::hasUserConf()) {
self::$login_ok = false;
return false;
}
- switch (FreshRSS_Context::$system_conf->auth_type) {
+ switch (FreshRSS_Context::systemConf()->auth_type) {
case 'form':
- self::$login_ok = Minz_Session::paramString('passwordHash') === FreshRSS_Context::$user_conf->passwordHash;
+ self::$login_ok = Minz_Session::paramString('passwordHash') === FreshRSS_Context::userConf()->passwordHash;
break;
case 'http_auth':
- $current_user = Minz_User::name();
+ $current_user = Minz_User::name() ?? '';
self::$login_ok = strcasecmp($current_user, httpAuthUser()) === 0;
break;
case 'none':
@@ -138,12 +138,12 @@ class FreshRSS_Auth {
* @return bool true if user has corresponding access, false else.
*/
public static function hasAccess(string $scope = 'general'): bool {
- if (FreshRSS_Context::$user_conf == null) {
+ if (!FreshRSS_Context::hasUserConf()) {
return false;
}
$currentUser = Minz_User::name();
- $isAdmin = FreshRSS_Context::$user_conf->is_admin;
- $default_user = FreshRSS_Context::$system_conf->default_user;
+ $isAdmin = FreshRSS_Context::userConf()->is_admin;
+ $default_user = FreshRSS_Context::systemConf()->default_user;
$ok = self::$login_ok;
switch ($scope) {
case 'general':
@@ -180,11 +180,11 @@ class FreshRSS_Auth {
}
}
if ($username == '') {
- $username = FreshRSS_Context::$system_conf->default_user;
+ $username = FreshRSS_Context::systemConf()->default_user;
}
Minz_User::change($username);
- switch (FreshRSS_Context::$system_conf->auth_type) {
+ switch (FreshRSS_Context::systemConf()->auth_type) {
case 'form':
Minz_Session::_param('passwordHash');
FreshRSS_FormAuth::deleteCookie();
@@ -202,20 +202,20 @@ class FreshRSS_Auth {
* Return if authentication is enabled on this instance of FRSS.
*/
public static function accessNeedsLogin(): bool {
- return FreshRSS_Context::$system_conf->auth_type !== 'none';
+ return FreshRSS_Context::systemConf()->auth_type !== 'none';
}
/**
* Return if authentication requires a PHP action.
*/
public static function accessNeedsAction(): bool {
- return FreshRSS_Context::$system_conf->auth_type === 'form';
+ return FreshRSS_Context::systemConf()->auth_type === 'form';
}
public static function csrfToken(): string {
$csrf = Minz_Session::paramString('csrf');
if ($csrf == '') {
- $salt = FreshRSS_Context::$system_conf->salt;
+ $salt = FreshRSS_Context::systemConf()->salt;
$csrf = sha1($salt . uniqid('' . random_int(0, mt_getrandmax()), true));
Minz_Session::_param('csrf', $csrf);
}