diff options
| author | 2020-06-14 19:50:09 +0200 | |
|---|---|---|
| committer | 2020-06-14 19:50:09 +0200 | |
| commit | caeb660f29d13db62d5381c262aa03e12f201ea2 (patch) | |
| tree | bbe593de7c584f15c67c1e4c96f0852c2c5637ed /app/Controllers/userController.php | |
| parent | 6edbeaaf6add5e6f60d949301a05ef42fbdc6afd (diff) | |
Add a way to disable/enable users (#3056)
If you want to block users without deleting their account, you can now
disable them from the interface.
Diffstat (limited to 'app/Controllers/userController.php')
| -rw-r--r-- | app/Controllers/userController.php | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php index 491350ef3..6e7908df3 100644 --- a/app/Controllers/userController.php +++ b/app/Controllers/userController.php @@ -191,6 +191,12 @@ class FreshRSS_user_Controller extends Minz_ActionController { case 'demote': $this->demoteAction(); break; + case 'enable': + $this->enableAction(); + break; + case 'disable': + $this->disableAction(); + break; } } @@ -332,6 +338,7 @@ class FreshRSS_user_Controller extends Minz_ActionController { $ok = self::createUser($new_user_name, $email, $passwordPlain, array( 'language' => Minz_Request::param('new_user_language', FreshRSS_Context::$user_conf->language), 'is_admin' => Minz_Request::paramBoolean('new_user_is_admin'), + 'enabled' => true, )); Minz_Request::_param('new_user_passwordPlain'); //Discard plain-text password ASAP $_POST['new_user_passwordPlain'] = ''; @@ -550,14 +557,22 @@ class FreshRSS_user_Controller extends Minz_ActionController { } public function promoteAction() { - $this->switchAdminAction(true); + $this->toggleAction('is_admin', true); } public function demoteAction() { - $this->switchAdminAction(false); + $this->toggleAction('is_admin', false); + } + + public function enableAction() { + $this->toggleAction('enabled', true); + } + + public function disableAction() { + $this->toggleAction('enabled', false); } - private function switchAdminAction($isAdmin) { + private function toggleAction($field, $value) { if (!FreshRSS_Auth::hasAccess('admin')) { Minz_Error::error(403); } @@ -575,9 +590,10 @@ class FreshRSS_user_Controller extends Minz_ActionController { Minz_Error::error(500); } - $userConfig->_param('is_admin', $isAdmin); + $userConfig->_param($field, $value); $ok = $userConfig->save(); + FreshRSS_UserDAO::touch($username); if ($ok) { Minz_Request::good(_t('feedback.user.updated', $username), array('c' => 'user', 'a' => 'manage')); @@ -597,7 +613,6 @@ class FreshRSS_user_Controller extends Minz_ActionController { Minz_Error::error(404); } - $this->view->isDefaultUser = $username === FreshRSS_Context::$system_conf->default_user; $this->view->username = $username; $this->view->details = $this->retrieveUserDetails($username); } @@ -615,8 +630,10 @@ class FreshRSS_user_Controller extends Minz_ActionController { 'database_size' => $databaseDAO->size(), 'language' => $userConfiguration->language, 'mail_login' => $userConfiguration->mail_login, + 'enabled' => $userConfiguration->enabled, 'is_admin' => $userConfiguration->is_admin, 'last_user_activity' => date('c', FreshRSS_UserDAO::mtime($username)), + 'is_default' => FreshRSS_Context::$system_conf->default_user === $username, ); } } |
