userController.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  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. * @todo handle r redirection in Minz_Request::forward directly?
  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 = urldecode(Minz_Request::paramString('r', true));
  320. if ($redirect_url === '') {
  321. $redirect_url = ['c' => 'user', 'a' => 'manage'];
  322. }
  323. Minz_Request::forward($redirect_url, true);
  324. }
  325. public static function deleteUser(string $username): bool {
  326. $ok = self::checkUsername($username);
  327. if ($ok) {
  328. $default_user = FreshRSS_Context::$system_conf->default_user;
  329. $ok &= (strcasecmp($username, $default_user) !== 0); //It is forbidden to delete the default user
  330. }
  331. $user_data = join_path(DATA_PATH, 'users', $username);
  332. $ok &= is_dir($user_data);
  333. if ($ok) {
  334. FreshRSS_fever_Util::deleteKey($username);
  335. $oldUserDAO = FreshRSS_Factory::createUserDao($username);
  336. $ok &= $oldUserDAO->deleteUser();
  337. $ok &= recursive_unlink($user_data);
  338. array_map('unlink', glob(PSHB_PATH . '/feeds/*/' . $username . '.txt'));
  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. array('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. array('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. array('c' => 'index', 'a' => 'index')
  397. );
  398. } else {
  399. Minz_Request::bad(
  400. _t('user.email.validation.feedback.error'),
  401. array('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(array(
  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 = array('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 = urldecode(Minz_Request::paramString('r', true));
  461. if ($redirect_url === '') {
  462. $redirect_url = ['c' => 'user', 'a' => 'manage'];
  463. }
  464. if (Minz_Request::isPost()) {
  465. $ok = true;
  466. if ($self_deletion) {
  467. // We check the password if it’s a self-destruction
  468. $nonce = Minz_Session::param('nonce', '');
  469. $challenge = Minz_Request::paramString('challenge');
  470. $ok &= FreshRSS_FormAuth::checkCredentials(
  471. $username, FreshRSS_Context::$user_conf->passwordHash,
  472. $nonce, $challenge
  473. );
  474. }
  475. if ($ok) {
  476. $ok &= self::deleteUser($username);
  477. }
  478. if ($ok && $self_deletion) {
  479. FreshRSS_Auth::removeAccess();
  480. $redirect_url = array('c' => 'index', 'a' => 'index');
  481. }
  482. invalidateHttpCache();
  483. if ($ok) {
  484. Minz_Request::setGoodNotification(_t('feedback.user.deleted', $username));
  485. } else {
  486. Minz_Request::setBadNotification(_t('feedback.user.deleted.error', $username));
  487. }
  488. }
  489. Minz_Request::forward($redirect_url, true);
  490. }
  491. public function promoteAction(): void {
  492. $this->toggleAction('is_admin', true);
  493. }
  494. public function demoteAction(): void {
  495. $this->toggleAction('is_admin', false);
  496. }
  497. public function enableAction(): void {
  498. $this->toggleAction('enabled', true);
  499. }
  500. public function disableAction(): void {
  501. $this->toggleAction('enabled', false);
  502. }
  503. private function toggleAction(string $field, bool $value): void {
  504. if (!FreshRSS_Auth::hasAccess('admin')) {
  505. Minz_Error::error(403);
  506. }
  507. if (!Minz_Request::isPost()) {
  508. Minz_Error::error(403);
  509. }
  510. $username = Minz_Request::paramString('username');
  511. if (!FreshRSS_UserDAO::exists($username)) {
  512. Minz_Error::error(404);
  513. }
  514. if (null === $userConfig = get_user_configuration($username)) {
  515. Minz_Error::error(500);
  516. }
  517. $userConfig->_param($field, $value);
  518. $ok = $userConfig->save();
  519. FreshRSS_UserDAO::touch($username);
  520. if ($ok) {
  521. Minz_Request::good(_t('feedback.user.updated', $username), array('c' => 'user', 'a' => 'manage'));
  522. } else {
  523. Minz_Request::bad(_t('feedback.user.updated.error', $username),
  524. array('c' => 'user', 'a' => 'manage'));
  525. }
  526. }
  527. public function detailsAction(): void {
  528. if (!FreshRSS_Auth::hasAccess('admin')) {
  529. Minz_Error::error(403);
  530. }
  531. $username = Minz_Request::paramString('username');
  532. if (!FreshRSS_UserDAO::exists($username)) {
  533. Minz_Error::error(404);
  534. }
  535. $this->view->username = $username;
  536. $this->view->details = $this->retrieveUserDetails($username);
  537. }
  538. /** @return array{'feed_count':int|false,'article_count':int|false,'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 array(
  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. }