userController.php 19 KB

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