aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2021-01-02 21:20:19 +0100
committerGravatar GitHub <noreply@github.com> 2021-01-02 21:20:19 +0100
commit9c6682e7edf8cbad828088cbeeef66c7ecefdd9a (patch)
treec8c8a6ba34d49d22497a14ddaf18ae97d8cd5bb1 /app/Controllers
parent7bc2cc5825547f5b5cf15005fda937e06065b45d (diff)
Avoid manual initialisations of system or user configuration (#3070)
* Avoid manual intialisations of system or user configuration More consistent use of Context * Simplify FreshRSS_Context::initUser * Remove a few manual get_user_configuration * A bit of debugging * Fix context user init * Fix install * Fix concurrency Concurrent requests could lead to bad race condition * Fix actualize cron Fix case when system i initialised several times
Diffstat (limited to 'app/Controllers')
-rw-r--r--app/Controllers/authController.php25
-rw-r--r--app/Controllers/errorController.php2
-rwxr-xr-xapp/Controllers/javascriptController.php5
3 files changed, 16 insertions, 16 deletions
diff --git a/app/Controllers/authController.php b/app/Controllers/authController.php
index 342c577e2..403c92790 100644
--- a/app/Controllers/authController.php
+++ b/app/Controllers/authController.php
@@ -112,8 +112,7 @@ class FreshRSS_auth_Controller extends Minz_ActionController {
Minz_View::prependTitle(_t('gen.auth.login') . ' ยท ');
Minz_View::appendScript(Minz_Url::display('/scripts/bcrypt.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/bcrypt.min.js')));
- $conf = Minz_Configuration::get('system');
- $limits = $conf->limits;
+ $limits = FreshRSS_Context::$system_conf->limits;
$this->view->cookie_days = round($limits['cookie_duration'] / 86400, 1);
$isPOST = Minz_Request::isPost() && !Minz_Session::param('POST_to_GET');
@@ -124,38 +123,38 @@ class FreshRSS_auth_Controller extends Minz_ActionController {
$username = Minz_Request::param('username', '');
$challenge = Minz_Request::param('challenge', '');
- $conf = get_user_configuration($username);
- if ($conf == null) {
+ FreshRSS_Context::initUser($username);
+ if (FreshRSS_Context::$user_conf == null) {
//We do not test here whether the user exists, so most likely an internal error.
Minz_Error::error(403, array(_t('feedback.auth.login.invalid')), false);
return;
}
- if (!$conf->enabled) {
+ if (!FreshRSS_Context::$user_conf->enabled) {
Minz_Error::error(403, array(_t('feedback.auth.login.invalid')), false);
return;
}
$ok = FreshRSS_FormAuth::checkCredentials(
- $username, $conf->passwordHash, $nonce, $challenge
+ $username, FreshRSS_Context::$user_conf->passwordHash, $nonce, $challenge
);
if ($ok) {
// Set session parameter to give access to the user.
Minz_Session::_params([
'currentUser' => $username,
- 'passwordHash' => $conf->passwordHash,
+ 'passwordHash' => FreshRSS_Context::$user_conf->passwordHash,
'csrf' => false,
]);
FreshRSS_Auth::giveAccess();
// Set cookie parameter if nedded.
if (Minz_Request::param('keep_logged_in')) {
- FreshRSS_FormAuth::makeCookie($username, $conf->passwordHash);
+ FreshRSS_FormAuth::makeCookie($username, FreshRSS_Context::$user_conf->passwordHash);
} else {
FreshRSS_FormAuth::deleteCookie();
}
- Minz_Translate::init($conf->language);
+ Minz_Translate::init(FreshRSS_Context::$user_conf->language);
// All is good, go back to the index.
Minz_Request::good(_t('feedback.auth.login.success'),
@@ -183,12 +182,12 @@ class FreshRSS_auth_Controller extends Minz_ActionController {
FreshRSS_FormAuth::deleteCookie();
- $conf = get_user_configuration($username);
- if ($conf == null) {
+ FreshRSS_Context::initUser($username);
+ if (FreshRSS_Context::$user_conf == null) {
return;
}
- $s = $conf->passwordHash;
+ $s = FreshRSS_Context::$user_conf->passwordHash;
$ok = password_verify($password, $s);
unset($password);
if ($ok) {
@@ -199,7 +198,7 @@ class FreshRSS_auth_Controller extends Minz_ActionController {
]);
FreshRSS_Auth::giveAccess();
- Minz_Translate::init($conf->language);
+ Minz_Translate::init(FreshRSS_Context::$user_conf->language);
Minz_Request::good(_t('feedback.auth.login.success'),
array('c' => 'index', 'a' => 'index'));
diff --git a/app/Controllers/errorController.php b/app/Controllers/errorController.php
index a5f901fd4..ce6024406 100644
--- a/app/Controllers/errorController.php
+++ b/app/Controllers/errorController.php
@@ -33,10 +33,12 @@ class FreshRSS_error_Controller extends Minz_ActionController {
case 500:
header('HTTP/1.1 500 Internal Server Error');
$this->view->code = 'Error 500 - Internal Server Error';
+ $this->view->errorMessage = 'Error 500 - Internal Server Error';
break;
case 503:
header('HTTP/1.1 503 Service Unavailable');
$this->view->code = 'Error 503 - Service Unavailable';
+ $this->view->errorMessage = 'Error 503 - Service Unavailable';
break;
case 404:
default:
diff --git a/app/Controllers/javascriptController.php b/app/Controllers/javascriptController.php
index b22e2c127..40f0fc19a 100755
--- a/app/Controllers/javascriptController.php
+++ b/app/Controllers/javascriptController.php
@@ -29,11 +29,10 @@ class FreshRSS_javascript_Controller extends Minz_ActionController {
header('Pragma: no-cache');
$user = isset($_GET['user']) ? $_GET['user'] : '';
- if (FreshRSS_user_Controller::checkUsername($user)) {
+ if (FreshRSS_Context::initUser($user)) {
try {
$salt = FreshRSS_Context::$system_conf->salt;
- $conf = get_user_configuration($user);
- $s = $conf->passwordHash;
+ $s = FreshRSS_Context::$user_conf->passwordHash;
if (strlen($s) >= 60) {
$this->view->salt1 = substr($s, 0, 29); //CRYPT_BLOWFISH Salt: "$2a$", a two digit cost parameter, "$", and 22 characters from the alphabet "./0-9A-Za-z".
$this->view->nonce = sha1($salt . uniqid(mt_rand(), true));