userController.php 19 KB

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