aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers/authController.php
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/authController.php
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/authController.php')
-rw-r--r--app/Controllers/authController.php25
1 files changed, 12 insertions, 13 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'));