summaryrefslogtreecommitdiff
path: root/app/Controllers/userController.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2017-10-01 18:31:28 +0200
committerGravatar GitHub <noreply@github.com> 2017-10-01 18:31:28 +0200
commitceda55c75b158fc1cf4813fe0f258527754b9289 (patch)
tree7c84ac32cc845ab1d70ea5a3fb263c6613de34b0 /app/Controllers/userController.php
parentcb7ba3e47576aa1d0c3f53e5966f831e6540bbc3 (diff)
parentf241fc1841df89285ecb6f124f0d70198d712b2f (diff)
Merge pull request #1651 from FreshRSS/dev1.8.0
Release 1.8.0
Diffstat (limited to 'app/Controllers/userController.php')
-rw-r--r--app/Controllers/userController.php50
1 files changed, 30 insertions, 20 deletions
diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php
index 3cbbd8633..a58501186 100644
--- a/app/Controllers/userController.php
+++ b/app/Controllers/userController.php
@@ -44,6 +44,29 @@ class FreshRSS_user_Controller extends Minz_ActionController {
return preg_match('/^' . self::USERNAME_PATTERN . '$/', $username) === 1;
}
+ public static function updateContextUser($passwordPlain, $apiPasswordPlain, $userConfigUpdated = array()) {
+ if ($passwordPlain != '') {
+ $passwordHash = self::hashPassword($passwordPlain);
+ FreshRSS_Context::$user_conf->passwordHash = $passwordHash;
+ }
+
+ if ($apiPasswordPlain != '') {
+ $apiPasswordHash = self::hashPassword($apiPasswordPlain);
+ FreshRSS_Context::$user_conf->apiPasswordHash = $apiPasswordHash;
+ }
+
+ if (is_array($userConfigUpdated)) {
+ foreach ($userConfigUpdated as $configName => $configValue) {
+ if ($configValue !== null) {
+ FreshRSS_Context::$user_conf->_param($configName, $configValue);
+ }
+ }
+ }
+
+ $ok = FreshRSS_Context::$user_conf->save();
+ return $ok;
+ }
+
/**
* This action displays the user profile page.
*/
@@ -55,30 +78,17 @@ class FreshRSS_user_Controller extends Minz_ActionController {
));
if (Minz_Request::isPost()) {
- $ok = true;
-
$passwordPlain = Minz_Request::param('newPasswordPlain', '', true);
- if ($passwordPlain != '') {
- Minz_Request::_param('newPasswordPlain'); //Discard plain-text password ASAP
- $_POST['newPasswordPlain'] = '';
- $passwordHash = self::hashPassword($passwordPlain);
- $ok &= ($passwordHash != '');
- FreshRSS_Context::$user_conf->passwordHash = $passwordHash;
- }
- Minz_Session::_param('passwordHash', FreshRSS_Context::$user_conf->passwordHash);
+ Minz_Request::_param('newPasswordPlain'); //Discard plain-text password ASAP
+ $_POST['newPasswordPlain'] = '';
- $passwordPlain = Minz_Request::param('apiPasswordPlain', '', true);
- if ($passwordPlain != '') {
- $passwordHash = self::hashPassword($passwordPlain);
- $ok &= ($passwordHash != '');
- FreshRSS_Context::$user_conf->apiPasswordHash = $passwordHash;
- }
+ $apiPasswordPlain = Minz_Request::param('apiPasswordPlain', '', true);
- $current_token = FreshRSS_Context::$user_conf->token;
- $token = Minz_Request::param('token', $current_token);
- FreshRSS_Context::$user_conf->token = $token;
+ $ok = self::updateContextUser($passwordPlain, $apiPasswordPlain, array(
+ 'token' => Minz_Request::param('token', null),
+ ));
- $ok &= FreshRSS_Context::$user_conf->save();
+ Minz_Session::_param('passwordHash', FreshRSS_Context::$user_conf->passwordHash);
if ($ok) {
Minz_Request::good(_t('feedback.profile.updated'),