userController.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  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. $filenames = glob(PSHB_PATH . '/feeds/*/' . $username . '.txt');
  339. if (!empty($filenames)) {
  340. array_map('unlink', $filenames);
  341. }
  342. }
  343. return (bool)$ok;
  344. }
  345. /**
  346. * This action validates an email address, based on the token sent by email.
  347. * It also serves the main page when user is blocked.
  348. *
  349. * Request parameters are:
  350. * - username
  351. * - token
  352. *
  353. * This route works with GET requests since the URL is provided by email.
  354. * The security risks (e.g. forged URL by an attacker) are not very high so
  355. * it’s ok.
  356. *
  357. * It returns 404 error if `force_email_validation` is disabled or if the
  358. * user doesn’t exist.
  359. *
  360. * It returns 403 if user isn’t logged in and `username` param isn’t passed.
  361. */
  362. public function validateEmailAction(): void {
  363. if (!FreshRSS_Context::$system_conf->force_email_validation) {
  364. Minz_Error::error(404);
  365. }
  366. FreshRSS_View::prependTitle(_t('user.email.validation.title') . ' · ');
  367. $this->view->_layout('simple');
  368. $username = Minz_Request::paramString('username');
  369. $token = Minz_Request::paramString('token');
  370. if ($username !== '') {
  371. $user_config = get_user_configuration($username);
  372. } elseif (FreshRSS_Auth::hasAccess()) {
  373. $user_config = FreshRSS_Context::$user_conf;
  374. } else {
  375. Minz_Error::error(403);
  376. return;
  377. }
  378. if (!FreshRSS_UserDAO::exists($username) || $user_config === null) {
  379. Minz_Error::error(404);
  380. return;
  381. }
  382. if ($user_config->email_validation_token === '') {
  383. Minz_Request::good(
  384. _t('user.email.validation.feedback.unnecessary'),
  385. array('c' => 'index', 'a' => 'index')
  386. );
  387. }
  388. if ($token != '') {
  389. if ($user_config->email_validation_token !== $token) {
  390. Minz_Request::bad(
  391. _t('user.email.validation.feedback.wrong_token'),
  392. array('c' => 'user', 'a' => 'validateEmail')
  393. );
  394. }
  395. $user_config->email_validation_token = '';
  396. if ($user_config->save()) {
  397. Minz_Request::good(
  398. _t('user.email.validation.feedback.ok'),
  399. array('c' => 'index', 'a' => 'index')
  400. );
  401. } else {
  402. Minz_Request::bad(
  403. _t('user.email.validation.feedback.error'),
  404. array('c' => 'user', 'a' => 'validateEmail')
  405. );
  406. }
  407. }
  408. }
  409. /**
  410. * This action resends a validation email to the current user.
  411. *
  412. * It only acts on POST requests but doesn’t require any param (except the
  413. * CSRF token).
  414. *
  415. * It returns 403 error if the user is not logged in or 404 if request is
  416. * not POST. Else it redirects silently to the index if user has already
  417. * validated its email, or to the user#validateEmail route.
  418. */
  419. public function sendValidationEmailAction(): void {
  420. if (!FreshRSS_Auth::hasAccess()) {
  421. Minz_Error::error(403);
  422. }
  423. if (!Minz_Request::isPost()) {
  424. Minz_Error::error(404);
  425. }
  426. $username = Minz_User::name();
  427. $user_config = FreshRSS_Context::$user_conf;
  428. if ($user_config->email_validation_token === '') {
  429. Minz_Request::forward(array(
  430. 'c' => 'index',
  431. 'a' => 'index',
  432. ), true);
  433. }
  434. $mailer = new FreshRSS_User_Mailer();
  435. $ok = $mailer->send_email_need_validation($username, $user_config);
  436. $redirect_url = array('c' => 'user', 'a' => 'validateEmail');
  437. if ($ok) {
  438. Minz_Request::good(
  439. _t('user.email.validation.feedback.email_sent'),
  440. $redirect_url
  441. );
  442. } else {
  443. Minz_Request::bad(
  444. _t('user.email.validation.feedback.email_failed'),
  445. $redirect_url
  446. );
  447. }
  448. }
  449. /**
  450. * This action delete an existing user.
  451. *
  452. * Request parameter is:
  453. * - username
  454. *
  455. * @todo clean up this method. Idea: create a User->clean() method.
  456. */
  457. public function deleteAction(): void {
  458. $username = Minz_Request::paramString('username');
  459. $self_deletion = Minz_User::name() === $username;
  460. if (!FreshRSS_Auth::hasAccess('admin') && !$self_deletion) {
  461. Minz_Error::error(403);
  462. }
  463. $redirect_url = urldecode(Minz_Request::paramString('r', true));
  464. if ($redirect_url === '') {
  465. $redirect_url = ['c' => 'user', 'a' => 'manage'];
  466. }
  467. if (Minz_Request::isPost()) {
  468. $ok = true;
  469. if ($self_deletion) {
  470. // We check the password if it’s a self-destruction
  471. $nonce = Minz_Session::param('nonce', '');
  472. $challenge = Minz_Request::paramString('challenge');
  473. $ok &= FreshRSS_FormAuth::checkCredentials(
  474. $username, FreshRSS_Context::$user_conf->passwordHash,
  475. $nonce, $challenge
  476. );
  477. }
  478. if ($ok) {
  479. $ok &= self::deleteUser($username);
  480. }
  481. if ($ok && $self_deletion) {
  482. FreshRSS_Auth::removeAccess();
  483. $redirect_url = array('c' => 'index', 'a' => 'index');
  484. }
  485. invalidateHttpCache();
  486. if ($ok) {
  487. Minz_Request::setGoodNotification(_t('feedback.user.deleted', $username));
  488. } else {
  489. Minz_Request::setBadNotification(_t('feedback.user.deleted.error', $username));
  490. }
  491. }
  492. Minz_Request::forward($redirect_url, true);
  493. }
  494. public function promoteAction(): void {
  495. $this->toggleAction('is_admin', true);
  496. }
  497. public function demoteAction(): void {
  498. $this->toggleAction('is_admin', false);
  499. }
  500. public function enableAction(): void {
  501. $this->toggleAction('enabled', true);
  502. }
  503. public function disableAction(): void {
  504. $this->toggleAction('enabled', false);
  505. }
  506. private function toggleAction(string $field, bool $value): void {
  507. if (!FreshRSS_Auth::hasAccess('admin')) {
  508. Minz_Error::error(403);
  509. }
  510. if (!Minz_Request::isPost()) {
  511. Minz_Error::error(403);
  512. }
  513. $username = Minz_Request::paramString('username');
  514. if (!FreshRSS_UserDAO::exists($username)) {
  515. Minz_Error::error(404);
  516. }
  517. if (null === $userConfig = get_user_configuration($username)) {
  518. Minz_Error::error(500);
  519. }
  520. $userConfig->_param($field, $value);
  521. $ok = $userConfig->save();
  522. FreshRSS_UserDAO::touch($username);
  523. if ($ok) {
  524. Minz_Request::good(_t('feedback.user.updated', $username), array('c' => 'user', 'a' => 'manage'));
  525. } else {
  526. Minz_Request::bad(_t('feedback.user.updated.error', $username),
  527. array('c' => 'user', 'a' => 'manage'));
  528. }
  529. }
  530. public function detailsAction(): void {
  531. if (!FreshRSS_Auth::hasAccess('admin')) {
  532. Minz_Error::error(403);
  533. }
  534. $username = Minz_Request::paramString('username');
  535. if (!FreshRSS_UserDAO::exists($username)) {
  536. Minz_Error::error(404);
  537. }
  538. $this->view->username = $username;
  539. $this->view->details = $this->retrieveUserDetails($username);
  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. }