userController.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. <?php
  2. /**
  3. * Controller to handle user actions.
  4. */
  5. class FreshRSS_user_Controller extends FreshRSS_ActionController {
  6. /**
  7. * The username is also used as folder name, file name, and part of SQL table name.
  8. * '_' is a reserved internal username.
  9. */
  10. const USERNAME_PATTERN = '([0-9a-zA-Z_][0-9a-zA-Z_.@-]{1,38}|[0-9a-zA-Z])';
  11. public static function checkUsername(string $username): bool {
  12. return preg_match('/^' . self::USERNAME_PATTERN . '$/', $username) === 1;
  13. }
  14. public static function userExists(string $username): bool {
  15. return @file_exists(USERS_PATH . '/' . $username . '/config.php');
  16. }
  17. /** @param array<string,mixed> $userConfigUpdated */
  18. public static function updateUser(string $user, ?string $email, string $passwordPlain, array $userConfigUpdated = []): bool {
  19. $userConfig = get_user_configuration($user);
  20. if ($userConfig === null) {
  21. return false;
  22. }
  23. if ($email !== null && $userConfig->mail_login !== $email) {
  24. $userConfig->mail_login = $email;
  25. if (FreshRSS_Context::$system_conf->force_email_validation) {
  26. $salt = FreshRSS_Context::$system_conf->salt;
  27. $userConfig->email_validation_token = sha1($salt . uniqid('' . mt_rand(), true));
  28. $mailer = new FreshRSS_User_Mailer();
  29. $mailer->send_email_need_validation($user, $userConfig);
  30. }
  31. }
  32. if ($passwordPlain != '') {
  33. $passwordHash = FreshRSS_password_Util::hash($passwordPlain);
  34. $userConfig->passwordHash = $passwordHash;
  35. }
  36. foreach ($userConfigUpdated as $configName => $configValue) {
  37. if ($configValue !== null) {
  38. $userConfig->_param($configName, $configValue);
  39. }
  40. }
  41. $ok = $userConfig->save();
  42. return $ok;
  43. }
  44. public function updateAction(): void {
  45. if (!FreshRSS_Auth::hasAccess('admin')) {
  46. Minz_Error::error(403);
  47. }
  48. if (Minz_Request::isPost()) {
  49. $passwordPlain = Minz_Request::paramString('newPasswordPlain', true);
  50. Minz_Request::_param('newPasswordPlain'); //Discard plain-text password ASAP
  51. $_POST['newPasswordPlain'] = '';
  52. $username = Minz_Request::paramString('username');
  53. $ok = self::updateUser($username, null, $passwordPlain, [
  54. 'token' => Minz_Request::paramString('token') ?: null,
  55. ]);
  56. if ($ok) {
  57. $isSelfUpdate = Minz_User::name() === $username;
  58. if ($passwordPlain == '' || !$isSelfUpdate) {
  59. Minz_Request::good(_t('feedback.user.updated', $username), array('c' => 'user', 'a' => 'manage'));
  60. } else {
  61. Minz_Request::good(_t('feedback.profile.updated'), array('c' => 'index', 'a' => 'index'));
  62. }
  63. } else {
  64. Minz_Request::bad(_t('feedback.user.updated.error', $username), [ 'c' => 'user', 'a' => 'manage' ]);
  65. }
  66. }
  67. }
  68. /**
  69. * This action displays the user profile page.
  70. */
  71. public function profileAction(): void {
  72. if (!FreshRSS_Auth::hasAccess()) {
  73. Minz_Error::error(403);
  74. }
  75. $email_not_verified = FreshRSS_Context::$user_conf->email_validation_token != '';
  76. $this->view->disable_aside = false;
  77. if ($email_not_verified) {
  78. $this->view->_layout('simple');
  79. $this->view->disable_aside = true;
  80. }
  81. FreshRSS_View::prependTitle(_t('conf.profile.title') . ' · ');
  82. FreshRSS_View::appendScript(Minz_Url::display('/scripts/bcrypt.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/bcrypt.min.js')));
  83. if (Minz_Request::isPost()) {
  84. $system_conf = FreshRSS_Context::$system_conf;
  85. $user_config = FreshRSS_Context::$user_conf;
  86. $old_email = $user_config->mail_login;
  87. $email = Minz_Request::paramString('email');
  88. $passwordPlain = Minz_Request::paramString('newPasswordPlain', true);
  89. Minz_Request::_param('newPasswordPlain'); //Discard plain-text password ASAP
  90. $_POST['newPasswordPlain'] = '';
  91. if ($system_conf->force_email_validation && empty($email)) {
  92. Minz_Request::bad(
  93. _t('user.email.feedback.required'),
  94. array('c' => 'user', 'a' => 'profile')
  95. );
  96. }
  97. if (!empty($email) && !validateEmailAddress($email)) {
  98. Minz_Request::bad(
  99. _t('user.email.feedback.invalid'),
  100. array('c' => 'user', 'a' => 'profile')
  101. );
  102. }
  103. $ok = self::updateUser(
  104. Minz_User::name(),
  105. $email,
  106. $passwordPlain,
  107. [
  108. 'token' => Minz_Request::paramString('token') ?: null,
  109. ]
  110. );
  111. Minz_Session::_param('passwordHash', FreshRSS_Context::$user_conf->passwordHash);
  112. if ($ok) {
  113. if ($system_conf->force_email_validation && $email !== $old_email) {
  114. Minz_Request::good(_t('feedback.profile.updated'), array('c' => 'user', 'a' => 'validateEmail'));
  115. } elseif ($passwordPlain == '') {
  116. Minz_Request::good(_t('feedback.profile.updated'), array('c' => 'user', 'a' => 'profile'));
  117. } else {
  118. Minz_Request::good(_t('feedback.profile.updated'), array('c' => 'index', 'a' => 'index'));
  119. }
  120. } else {
  121. Minz_Request::bad(_t('feedback.profile.error'), [ 'c' => 'user', 'a' => 'profile' ]);
  122. }
  123. }
  124. }
  125. public function purgeAction(): void {
  126. if (!FreshRSS_Auth::hasAccess('admin')) {
  127. Minz_Error::error(403);
  128. }
  129. if (Minz_Request::isPost()) {
  130. $username = Minz_Request::paramString('username');
  131. if (!FreshRSS_UserDAO::exists($username)) {
  132. Minz_Error::error(404);
  133. }
  134. $feedDAO = FreshRSS_Factory::createFeedDao($username);
  135. $feedDAO->purge();
  136. }
  137. }
  138. /**
  139. * This action displays the user management page.
  140. */
  141. public function manageAction(): void {
  142. if (!FreshRSS_Auth::hasAccess('admin')) {
  143. Minz_Error::error(403);
  144. }
  145. FreshRSS_View::prependTitle(_t('admin.user.title') . ' · ');
  146. if (Minz_Request::isPost()) {
  147. $action = Minz_Request::paramString('action');
  148. switch ($action) {
  149. case 'delete':
  150. $this->deleteAction();
  151. break;
  152. case 'update':
  153. $this->updateAction();
  154. break;
  155. case 'purge':
  156. $this->purgeAction();
  157. break;
  158. case 'promote':
  159. $this->promoteAction();
  160. break;
  161. case 'demote':
  162. $this->demoteAction();
  163. break;
  164. case 'enable':
  165. $this->enableAction();
  166. break;
  167. case 'disable':
  168. $this->disableAction();
  169. break;
  170. }
  171. }
  172. $this->view->show_email_field = FreshRSS_Context::$system_conf->force_email_validation;
  173. $this->view->current_user = Minz_Request::paramString('u');
  174. foreach (listUsers() as $user) {
  175. $this->view->users[$user] = $this->retrieveUserDetails($user);
  176. }
  177. }
  178. /** @param array<string,mixed> $userConfigOverride */
  179. public static function createUser(string $new_user_name, ?string $email, string $passwordPlain,
  180. array $userConfigOverride = [], bool $insertDefaultFeeds = true): bool {
  181. $userConfig = [];
  182. $customUserConfigPath = join_path(DATA_PATH, 'config-user.custom.php');
  183. if (file_exists($customUserConfigPath)) {
  184. $customUserConfig = include($customUserConfigPath);
  185. if (is_array($customUserConfig)) {
  186. $userConfig = $customUserConfig;
  187. }
  188. }
  189. $userConfig = array_merge($userConfig, $userConfigOverride);
  190. $ok = self::checkUsername($new_user_name);
  191. $homeDir = join_path(DATA_PATH, 'users', $new_user_name);
  192. $configPath = '';
  193. if ($ok) {
  194. $languages = Minz_Translate::availableLanguages();
  195. if (empty($userConfig['language']) || !in_array($userConfig['language'], $languages, true)) {
  196. $userConfig['language'] = 'en';
  197. }
  198. $ok &= !in_array(strtoupper($new_user_name), array_map('strtoupper', listUsers()), true); //Not an existing user, case-insensitive
  199. $configPath = join_path($homeDir, 'config.php');
  200. $ok &= !file_exists($configPath);
  201. }
  202. if ($ok) {
  203. if (!is_dir($homeDir)) {
  204. mkdir($homeDir, 0770, true);
  205. }
  206. $ok &= (file_put_contents($configPath, "<?php\n return " . var_export($userConfig, true) . ';') !== false);
  207. }
  208. if ($ok) {
  209. $newUserDAO = FreshRSS_Factory::createUserDao($new_user_name);
  210. $ok &= $newUserDAO->createUser();
  211. if ($ok && $insertDefaultFeeds) {
  212. $opmlPath = DATA_PATH . '/opml.xml';
  213. if (!file_exists($opmlPath)) {
  214. $opmlPath = FRESHRSS_PATH . '/opml.default.xml';
  215. }
  216. $importController = new FreshRSS_importExport_Controller();
  217. try {
  218. $importController->importFile($opmlPath, $opmlPath, $new_user_name);
  219. } catch (Exception $e) {
  220. Minz_Log::error('Error while importing default OPML for user ' . $new_user_name . ': ' . $e->getMessage());
  221. }
  222. }
  223. $ok &= self::updateUser($new_user_name, $email, $passwordPlain);
  224. }
  225. return (bool)$ok;
  226. }
  227. /**
  228. * This action creates a new user.
  229. *
  230. * Request parameters are:
  231. * - new_user_language
  232. * - new_user_name
  233. * - new_user_email
  234. * - new_user_passwordPlain
  235. * - r (i.e. a redirection url, optional)
  236. *
  237. * @todo clean up this method. Idea: write a method to init a user with basic information.
  238. */
  239. public function createAction(): void {
  240. if (!FreshRSS_Auth::hasAccess('admin') && max_registrations_reached()) {
  241. Minz_Error::error(403);
  242. }
  243. if (Minz_Request::isPost()) {
  244. $system_conf = FreshRSS_Context::$system_conf;
  245. $new_user_name = Minz_Request::paramString('new_user_name');
  246. $email = Minz_Request::paramString('new_user_email');
  247. $passwordPlain = Minz_Request::paramString('new_user_passwordPlain', true);
  248. $badRedirectUrl = [
  249. 'c' => Minz_Request::paramString('originController') ?: 'auth',
  250. 'a' => Minz_Request::paramString('originAction') ?: 'register',
  251. ];
  252. if (!self::checkUsername($new_user_name)) {
  253. Minz_Request::bad(
  254. _t('user.username.invalid'),
  255. $badRedirectUrl
  256. );
  257. }
  258. if (FreshRSS_UserDAO::exists($new_user_name)) {
  259. Minz_Request::bad(
  260. _t('user.username.taken', $new_user_name),
  261. $badRedirectUrl
  262. );
  263. }
  264. if (!FreshRSS_password_Util::check($passwordPlain)) {
  265. Minz_Request::bad(
  266. _t('user.password.invalid'),
  267. $badRedirectUrl
  268. );
  269. }
  270. $tos_enabled = file_exists(TOS_FILENAME);
  271. $accept_tos = Minz_Request::paramBoolean('accept_tos');
  272. if ($system_conf->force_email_validation && empty($email)) {
  273. Minz_Request::bad(
  274. _t('user.email.feedback.required'),
  275. $badRedirectUrl
  276. );
  277. }
  278. if (!empty($email) && !validateEmailAddress($email)) {
  279. Minz_Request::bad(
  280. _t('user.email.feedback.invalid'),
  281. $badRedirectUrl
  282. );
  283. }
  284. if ($tos_enabled && !$accept_tos) {
  285. Minz_Request::bad(
  286. _t('user.tos.feedback.invalid'),
  287. $badRedirectUrl
  288. );
  289. }
  290. $ok = self::createUser($new_user_name, $email, $passwordPlain, [
  291. 'language' => Minz_Request::paramString('new_user_language') ?: FreshRSS_Context::$user_conf->language,
  292. 'timezone' => Minz_Request::paramString('new_user_timezone'),
  293. 'is_admin' => Minz_Request::paramBoolean('new_user_is_admin'),
  294. 'enabled' => true,
  295. ]);
  296. Minz_Request::_param('new_user_passwordPlain'); //Discard plain-text password ASAP
  297. $_POST['new_user_passwordPlain'] = '';
  298. invalidateHttpCache();
  299. // If the user has admin access, it means he’s already logged in
  300. // and we don’t want to login with the new account. Otherwise, the
  301. // user just created its account himself so he probably wants to
  302. // get started immediately.
  303. if ($ok && !FreshRSS_Auth::hasAccess('admin')) {
  304. $user_conf = get_user_configuration($new_user_name);
  305. Minz_Session::_params([
  306. Minz_User::CURRENT_USER => $new_user_name,
  307. 'passwordHash' => $user_conf->passwordHash,
  308. 'csrf' => false,
  309. ]);
  310. FreshRSS_Auth::giveAccess();
  311. }
  312. if ($ok) {
  313. Minz_Request::setGoodNotification(_t('feedback.user.created', $new_user_name));
  314. } else {
  315. Minz_Request::setBadNotification(_t('feedback.user.created.error', $new_user_name));
  316. }
  317. }
  318. $redirect_url = ['c' => 'user', 'a' => 'manage'];
  319. Minz_Request::forward($redirect_url, true);
  320. }
  321. public static function deleteUser(string $username): bool {
  322. $ok = self::checkUsername($username);
  323. if ($ok) {
  324. $default_user = FreshRSS_Context::$system_conf->default_user;
  325. $ok &= (strcasecmp($username, $default_user) !== 0); //It is forbidden to delete the default user
  326. }
  327. $user_data = join_path(DATA_PATH, 'users', $username);
  328. $ok &= is_dir($user_data);
  329. if ($ok) {
  330. FreshRSS_fever_Util::deleteKey($username);
  331. $oldUserDAO = FreshRSS_Factory::createUserDao($username);
  332. $ok &= $oldUserDAO->deleteUser();
  333. $ok &= recursive_unlink($user_data);
  334. $filenames = glob(PSHB_PATH . '/feeds/*/' . $username . '.txt');
  335. if (!empty($filenames)) {
  336. array_map('unlink', $filenames);
  337. }
  338. }
  339. return (bool)$ok;
  340. }
  341. /**
  342. * This action validates an email address, based on the token sent by email.
  343. * It also serves the main page when user is blocked.
  344. *
  345. * Request parameters are:
  346. * - username
  347. * - token
  348. *
  349. * This route works with GET requests since the URL is provided by email.
  350. * The security risks (e.g. forged URL by an attacker) are not very high so
  351. * it’s ok.
  352. *
  353. * It returns 404 error if `force_email_validation` is disabled or if the
  354. * user doesn’t exist.
  355. *
  356. * It returns 403 if user isn’t logged in and `username` param isn’t passed.
  357. */
  358. public function validateEmailAction(): void {
  359. if (!FreshRSS_Context::$system_conf->force_email_validation) {
  360. Minz_Error::error(404);
  361. }
  362. FreshRSS_View::prependTitle(_t('user.email.validation.title') . ' · ');
  363. $this->view->_layout('simple');
  364. $username = Minz_Request::paramString('username');
  365. $token = Minz_Request::paramString('token');
  366. if ($username !== '') {
  367. $user_config = get_user_configuration($username);
  368. } elseif (FreshRSS_Auth::hasAccess()) {
  369. $user_config = FreshRSS_Context::$user_conf;
  370. } else {
  371. Minz_Error::error(403);
  372. return;
  373. }
  374. if (!FreshRSS_UserDAO::exists($username) || $user_config === null) {
  375. Minz_Error::error(404);
  376. return;
  377. }
  378. if ($user_config->email_validation_token === '') {
  379. Minz_Request::good(
  380. _t('user.email.validation.feedback.unnecessary'),
  381. array('c' => 'index', 'a' => 'index')
  382. );
  383. }
  384. if ($token != '') {
  385. if ($user_config->email_validation_token !== $token) {
  386. Minz_Request::bad(
  387. _t('user.email.validation.feedback.wrong_token'),
  388. array('c' => 'user', 'a' => 'validateEmail')
  389. );
  390. }
  391. $user_config->email_validation_token = '';
  392. if ($user_config->save()) {
  393. Minz_Request::good(
  394. _t('user.email.validation.feedback.ok'),
  395. array('c' => 'index', 'a' => 'index')
  396. );
  397. } else {
  398. Minz_Request::bad(
  399. _t('user.email.validation.feedback.error'),
  400. array('c' => 'user', 'a' => 'validateEmail')
  401. );
  402. }
  403. }
  404. }
  405. /**
  406. * This action resends a validation email to the current user.
  407. *
  408. * It only acts on POST requests but doesn’t require any param (except the
  409. * CSRF token).
  410. *
  411. * It returns 403 error if the user is not logged in or 404 if request is
  412. * not POST. Else it redirects silently to the index if user has already
  413. * validated its email, or to the user#validateEmail route.
  414. */
  415. public function sendValidationEmailAction(): void {
  416. if (!FreshRSS_Auth::hasAccess()) {
  417. Minz_Error::error(403);
  418. }
  419. if (!Minz_Request::isPost()) {
  420. Minz_Error::error(404);
  421. }
  422. $username = Minz_User::name();
  423. $user_config = FreshRSS_Context::$user_conf;
  424. if ($user_config->email_validation_token === '') {
  425. Minz_Request::forward(array(
  426. 'c' => 'index',
  427. 'a' => 'index',
  428. ), true);
  429. }
  430. $mailer = new FreshRSS_User_Mailer();
  431. $ok = $mailer->send_email_need_validation($username, $user_config);
  432. $redirect_url = array('c' => 'user', 'a' => 'validateEmail');
  433. if ($ok) {
  434. Minz_Request::good(
  435. _t('user.email.validation.feedback.email_sent'),
  436. $redirect_url
  437. );
  438. } else {
  439. Minz_Request::bad(
  440. _t('user.email.validation.feedback.email_failed'),
  441. $redirect_url
  442. );
  443. }
  444. }
  445. /**
  446. * This action delete an existing user.
  447. *
  448. * Request parameter is:
  449. * - username
  450. *
  451. * @todo clean up this method. Idea: create a User->clean() method.
  452. */
  453. public function deleteAction(): void {
  454. $username = Minz_Request::paramString('username');
  455. $self_deletion = Minz_User::name() === $username;
  456. if (!FreshRSS_Auth::hasAccess('admin') && !$self_deletion) {
  457. Minz_Error::error(403);
  458. }
  459. $redirect_url = ['c' => 'user', 'a' => 'manage'];
  460. if (Minz_Request::isPost()) {
  461. $ok = true;
  462. if ($self_deletion) {
  463. // We check the password if it’s a self-destruction
  464. $nonce = Minz_Session::param('nonce', '');
  465. $challenge = Minz_Request::paramString('challenge');
  466. $ok &= FreshRSS_FormAuth::checkCredentials(
  467. $username, FreshRSS_Context::$user_conf->passwordHash,
  468. $nonce, $challenge
  469. );
  470. }
  471. if ($ok) {
  472. $ok &= self::deleteUser($username);
  473. }
  474. if ($ok && $self_deletion) {
  475. FreshRSS_Auth::removeAccess();
  476. $redirect_url = array('c' => 'index', 'a' => 'index');
  477. }
  478. invalidateHttpCache();
  479. if ($ok) {
  480. Minz_Request::setGoodNotification(_t('feedback.user.deleted', $username));
  481. } else {
  482. Minz_Request::setBadNotification(_t('feedback.user.deleted.error', $username));
  483. }
  484. }
  485. Minz_Request::forward($redirect_url, true);
  486. }
  487. public function promoteAction(): void {
  488. $this->toggleAction('is_admin', true);
  489. }
  490. public function demoteAction(): void {
  491. $this->toggleAction('is_admin', false);
  492. }
  493. public function enableAction(): void {
  494. $this->toggleAction('enabled', true);
  495. }
  496. public function disableAction(): void {
  497. $this->toggleAction('enabled', false);
  498. }
  499. private function toggleAction(string $field, bool $value): void {
  500. if (!FreshRSS_Auth::hasAccess('admin')) {
  501. Minz_Error::error(403);
  502. }
  503. if (!Minz_Request::isPost()) {
  504. Minz_Error::error(403);
  505. }
  506. $username = Minz_Request::paramString('username');
  507. if (!FreshRSS_UserDAO::exists($username)) {
  508. Minz_Error::error(404);
  509. }
  510. if (null === $userConfig = get_user_configuration($username)) {
  511. Minz_Error::error(500);
  512. }
  513. $userConfig->_param($field, $value);
  514. $ok = $userConfig->save();
  515. FreshRSS_UserDAO::touch($username);
  516. if ($ok) {
  517. Minz_Request::good(_t('feedback.user.updated', $username), array('c' => 'user', 'a' => 'manage'));
  518. } else {
  519. Minz_Request::bad(_t('feedback.user.updated.error', $username),
  520. array('c' => 'user', 'a' => 'manage'));
  521. }
  522. }
  523. public function detailsAction(): void {
  524. if (!FreshRSS_Auth::hasAccess('admin')) {
  525. Minz_Error::error(403);
  526. }
  527. $username = Minz_Request::paramString('username');
  528. if (!FreshRSS_UserDAO::exists($username)) {
  529. Minz_Error::error(404);
  530. }
  531. if (Minz_Request::paramBoolean('ajax')) {
  532. $this->view->_layout(null);
  533. }
  534. $this->view->username = $username;
  535. $this->view->details = $this->retrieveUserDetails($username);
  536. FreshRSS_View::prependTitle($username . ' · ' . _t('gen.menu.user_management') . ' · ');
  537. }
  538. /** @return array{'feed_count':int,'article_count':int,'database_size':int,'language':string,'mail_login':string,'enabled':bool,'is_admin':bool,'last_user_activity':string,'is_default':bool} */
  539. private function retrieveUserDetails(string $username): array {
  540. $feedDAO = FreshRSS_Factory::createFeedDao($username);
  541. $entryDAO = FreshRSS_Factory::createEntryDao($username);
  542. $databaseDAO = FreshRSS_Factory::createDatabaseDAO($username);
  543. $userConfiguration = get_user_configuration($username);
  544. return [
  545. 'feed_count' => $feedDAO->count(),
  546. 'article_count' => $entryDAO->count(),
  547. 'database_size' => $databaseDAO->size(),
  548. 'language' => $userConfiguration->language,
  549. 'mail_login' => $userConfiguration->mail_login,
  550. 'enabled' => $userConfiguration->enabled,
  551. 'is_admin' => $userConfiguration->is_admin,
  552. 'last_user_activity' => date('c', FreshRSS_UserDAO::mtime($username)) ?: '',
  553. 'is_default' => FreshRSS_Context::$system_conf->default_user === $username,
  554. ];
  555. }
  556. }