diff options
| author | 2021-08-14 12:22:42 +0200 | |
|---|---|---|
| committer | 2021-08-14 12:22:42 +0200 | |
| commit | 7d83321286efc37162521f4302cf17f03c317020 (patch) | |
| tree | 4306a63572b04de0bc94e4ced0fff3d0c23866ed /app/Models/Context.php | |
| parent | 92ae9c89a4356abc94f2ec5c96a1b783f933fb18 (diff) | |
Better catch when a user does not exists (#3751)
#fix https://github.com/FreshRSS/FreshRSS/issues/3735
Before, we were relying on an exception during the first stages of user initalisation. Now the check is explicit and cleaner, producing a more appropriate HTTP response for the API.
Diffstat (limited to 'app/Models/Context.php')
| -rw-r--r-- | app/Models/Context.php | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/app/Models/Context.php b/app/Models/Context.php index 4f18165c0..14bca866c 100644 --- a/app/Models/Context.php +++ b/app/Models/Context.php @@ -60,7 +60,7 @@ class FreshRSS_Context { /** * Initialize the context for the current user. */ - public static function initUser($username = '') { + public static function initUser($username = '', $userMustExist = true) { FreshRSS_Context::$user_conf = null; if (!isset($_SESSION)) { Minz_Session::init('FreshRSS'); @@ -70,7 +70,8 @@ class FreshRSS_Context { if ($username == '') { $username = Minz_Session::param('currentUser', ''); } - if ($username === '_' || FreshRSS_user_Controller::checkUsername($username)) { + if (($username === '_' || FreshRSS_user_Controller::checkUsername($username)) && + (!$userMustExist || FreshRSS_user_Controller::userExists($username))) { try { //TODO: Keep in session what we need instead of always reloading from disk Minz_Configuration::register('user', |
