Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

741 lines
21 KiB

4 years ago
4 years ago
4 years ago
  1. <?php
  2. /**
  3. * @file src/Model/User.php
  4. * @brief This file includes the User class with user related database functions
  5. */
  6. namespace Friendica\Model;
  7. use DivineOmega\PasswordExposed\PasswordStatus;
  8. use Friendica\Core\Addon;
  9. use Friendica\Core\Config;
  10. use Friendica\Core\L10n;
  11. use Friendica\Core\PConfig;
  12. use Friendica\Core\System;
  13. use Friendica\Core\Worker;
  14. use Friendica\Database\DBM;
  15. use Friendica\Model\Contact;
  16. use Friendica\Model\Group;
  17. use Friendica\Model\Photo;
  18. use Friendica\Object\Image;
  19. use Friendica\Util\Crypto;
  20. use Friendica\Util\DateTimeFormat;
  21. use Friendica\Util\Network;
  22. use dba;
  23. use Exception;
  24. use LightOpenID;
  25. use function password_exposed;
  26. require_once 'boot.php';
  27. require_once 'include/dba.php';
  28. require_once 'include/enotify.php';
  29. require_once 'include/text.php';
  30. /**
  31. * @brief This class handles User related functions
  32. */
  33. class User
  34. {
  35. /**
  36. * @brief Get owner data by user id
  37. *
  38. * @param int $uid
  39. * @return boolean|array
  40. */
  41. public static function getOwnerDataById($uid) {
  42. $r = dba::fetch_first("SELECT
  43. `contact`.*,
  44. `user`.`prvkey` AS `uprvkey`,
  45. `user`.`timezone`,
  46. `user`.`nickname`,
  47. `user`.`sprvkey`,
  48. `user`.`spubkey`,
  49. `user`.`page-flags`,
  50. `user`.`account-type`,
  51. `user`.`prvnets`
  52. FROM `contact`
  53. INNER JOIN `user`
  54. ON `user`.`uid` = `contact`.`uid`
  55. WHERE `contact`.`uid` = ?
  56. AND `contact`.`self`
  57. LIMIT 1",
  58. $uid
  59. );
  60. if (!DBM::is_result($r)) {
  61. return false;
  62. }
  63. return $r;
  64. }
  65. /**
  66. * @brief Get owner data by nick name
  67. *
  68. * @param int $nick
  69. * @return boolean|array
  70. */
  71. public static function getOwnerDataByNick($nick)
  72. {
  73. $user = dba::selectFirst('user', ['uid'], ['nickname' => $nick]);
  74. if (!DBM::is_result($user)) {
  75. return false;
  76. }
  77. return self::getOwnerDataById($user['uid']);
  78. }
  79. /**
  80. * @brief Returns the default group for a given user and network
  81. *
  82. * @param int $uid User id
  83. * @param string $network network name
  84. *
  85. * @return int group id
  86. */
  87. public static function getDefaultGroup($uid, $network = '')
  88. {
  89. $default_group = 0;
  90. if ($network == NETWORK_OSTATUS) {
  91. $default_group = PConfig::get($uid, "ostatus", "default_group");
  92. }
  93. if ($default_group != 0) {
  94. return $default_group;
  95. }
  96. $user = dba::selectFirst('user', ['def_gid'], ['uid' => $uid]);
  97. if (DBM::is_result($user)) {
  98. $default_group = $user["def_gid"];
  99. }
  100. return $default_group;
  101. }
  102. /**
  103. * Authenticate a user with a clear text password
  104. *
  105. * @brief Authenticate a user with a clear text password
  106. * @param mixed $user_info
  107. * @param string $password
  108. * @return int|boolean
  109. * @deprecated since version 3.6
  110. * @see User::getIdFromPasswordAuthentication()
  111. */
  112. public static function authenticate($user_info, $password)
  113. {
  114. try {
  115. return self::getIdFromPasswordAuthentication($user_info, $password);
  116. } catch (Exception $ex) {
  117. return false;
  118. }
  119. }
  120. /**
  121. * Returns the user id associated with a successful password authentication
  122. *
  123. * @brief Authenticate a user with a clear text password
  124. * @param mixed $user_info
  125. * @param string $password
  126. * @return int User Id if authentication is successful
  127. * @throws Exception
  128. */
  129. public static function getIdFromPasswordAuthentication($user_info, $password)
  130. {
  131. $user = self::getAuthenticationInfo($user_info);
  132. if (strpos($user['password'], '$') === false) {
  133. //Legacy hash that has not been replaced by a new hash yet
  134. if (self::hashPasswordLegacy($password) === $user['password']) {
  135. self::updatePassword($user['uid'], $password);
  136. return $user['uid'];
  137. }
  138. } elseif (!empty($user['legacy_password'])) {
  139. //Legacy hash that has been double-hashed and not replaced by a new hash yet
  140. //Warning: `legacy_password` is not necessary in sync with the content of `password`
  141. if (password_verify(self::hashPasswordLegacy($password), $user['password'])) {
  142. self::updatePassword($user['uid'], $password);
  143. return $user['uid'];
  144. }
  145. } elseif (password_verify($password, $user['password'])) {
  146. //New password hash
  147. if (password_needs_rehash($user['password'], PASSWORD_DEFAULT)) {
  148. self::updatePassword($user['uid'], $password);
  149. }
  150. return $user['uid'];
  151. }
  152. throw new Exception(L10n::t('Login failed'));
  153. }
  154. /**
  155. * Returns authentication info from various parameters types
  156. *
  157. * User info can be any of the following:
  158. * - User DB object
  159. * - User Id
  160. * - User email or username or nickname
  161. * - User array with at least the uid and the hashed password
  162. *
  163. * @param mixed $user_info
  164. * @return array
  165. * @throws Exception
  166. */
  167. private static function getAuthenticationInfo($user_info)
  168. {
  169. $user = null;
  170. if (is_object($user_info) || is_array($user_info)) {
  171. if (is_object($user_info)) {
  172. $user = (array) $user_info;
  173. } else {
  174. $user = $user_info;
  175. }
  176. if (!isset($user['uid'])
  177. || !isset($user['password'])
  178. || !isset($user['legacy_password'])
  179. ) {
  180. throw new Exception(L10n::t('Not enough information to authenticate'));
  181. }
  182. } elseif (is_int($user_info) || is_string($user_info)) {
  183. if (is_int($user_info)) {
  184. $user = dba::selectFirst('user', ['uid', 'password', 'legacy_password'],
  185. [
  186. 'uid' => $user_info,
  187. 'blocked' => 0,
  188. 'account_expired' => 0,
  189. 'account_removed' => 0,
  190. 'verified' => 1
  191. ]
  192. );
  193. } else {
  194. $fields = ['uid', 'password', 'legacy_password'];
  195. $condition = ["(`email` = ? OR `username` = ? OR `nickname` = ?)
  196. AND NOT `blocked` AND NOT `account_expired` AND NOT `account_removed` AND `verified`",
  197. $user_info, $user_info, $user_info];
  198. $user = dba::selectFirst('user', $fields, $condition);
  199. }
  200. if (!DBM::is_result($user)) {
  201. throw new Exception(L10n::t('User not found'));
  202. }
  203. }
  204. return $user;
  205. }
  206. /**
  207. * Generates a human-readable random password
  208. *
  209. * @return string
  210. */
  211. public static function generateNewPassword()
  212. {
  213. return autoname(6) . mt_rand(100, 9999);
  214. }
  215. /**
  216. * Checks if the provided plaintext password has been exposed or not
  217. *
  218. * @param string $password
  219. * @return bool
  220. */
  221. public static function isPasswordExposed($password)
  222. {
  223. return password_exposed($password) === PasswordStatus::EXPOSED;
  224. }
  225. /**
  226. * Legacy hashing function, kept for password migration purposes
  227. *
  228. * @param string $password
  229. * @return string
  230. */
  231. private static function hashPasswordLegacy($password)
  232. {
  233. return hash('whirlpool', $password);
  234. }
  235. /**
  236. * Global user password hashing function
  237. *
  238. * @param string $password
  239. * @return string
  240. */
  241. public static function hashPassword($password)
  242. {
  243. if (!trim($password)) {
  244. throw new Exception(L10n::t('Password can\'t be empty'));
  245. }
  246. return password_hash($password, PASSWORD_DEFAULT);
  247. }
  248. /**
  249. * Updates a user row with a new plaintext password
  250. *
  251. * @param int $uid
  252. * @param string $password
  253. * @return bool
  254. */
  255. public static function updatePassword($uid, $password)
  256. {
  257. return self::updatePasswordHashed($uid, self::hashPassword($password));
  258. }
  259. /**
  260. * Updates a user row with a new hashed password.
  261. * Empties the password reset token field just in case.
  262. *
  263. * @param int $uid
  264. * @param string $pasword_hashed
  265. * @return bool
  266. */
  267. private static function updatePasswordHashed($uid, $pasword_hashed)
  268. {
  269. $fields = [
  270. 'password' => $pasword_hashed,
  271. 'pwdreset' => null,
  272. 'pwdreset_time' => null,
  273. 'legacy_password' => false
  274. ];
  275. return dba::update('user', $fields, ['uid' => $uid]);
  276. }
  277. /**
  278. * @brief Checks if a nickname is in the list of the forbidden nicknames
  279. *
  280. * Check if a nickname is forbidden from registration on the node by the
  281. * admin. Forbidden nicknames (e.g. role namess) can be configured in the
  282. * admin panel.
  283. *
  284. * @param string $nickname The nickname that should be checked
  285. * @return boolean True is the nickname is blocked on the node
  286. */
  287. public static function isNicknameBlocked($nickname)
  288. {
  289. $forbidden_nicknames = Config::get('system', 'forbidden_nicknames', '');
  290. // if the config variable is empty return false
  291. if (!x($forbidden_nicknames)) {
  292. return false;
  293. }
  294. // check if the nickname is in the list of blocked nicknames
  295. $forbidden = explode(',', $forbidden_nicknames);
  296. $forbidden = array_map('trim', $forbidden);
  297. if (in_array(strtolower($nickname), $forbidden)) {
  298. return true;
  299. }
  300. // else return false
  301. return false;
  302. }
  303. /**
  304. * @brief Catch-all user creation function
  305. *
  306. * Creates a user from the provided data array, either form fields or OpenID.
  307. * Required: { username, nickname, email } or { openid_url }
  308. *
  309. * Performs the following:
  310. * - Sends to the OpenId auth URL (if relevant)
  311. * - Creates new key pairs for crypto
  312. * - Create self-contact
  313. * - Create profile image
  314. *
  315. * @param array $data
  316. * @return string
  317. * @throw Exception
  318. */
  319. public static function create(array $data)
  320. {
  321. $a = get_app();
  322. $return = ['user' => null, 'password' => ''];
  323. $using_invites = Config::get('system', 'invitation_only');
  324. $num_invites = Config::get('system', 'number_invites');
  325. $invite_id = x($data, 'invite_id') ? notags(trim($data['invite_id'])) : '';
  326. $username = x($data, 'username') ? notags(trim($data['username'])) : '';
  327. $nickname = x($data, 'nickname') ? notags(trim($data['nickname'])) : '';
  328. $email = x($data, 'email') ? notags(trim($data['email'])) : '';
  329. $openid_url = x($data, 'openid_url') ? notags(trim($data['openid_url'])) : '';
  330. $photo = x($data, 'photo') ? notags(trim($data['photo'])) : '';
  331. $password = x($data, 'password') ? trim($data['password']) : '';
  332. $password1 = x($data, 'password1') ? trim($data['password1']) : '';
  333. $confirm = x($data, 'confirm') ? trim($data['confirm']) : '';
  334. $blocked = x($data, 'blocked') ? intval($data['blocked']) : 0;
  335. $verified = x($data, 'verified') ? intval($data['verified']) : 0;
  336. $language = x($data, 'language') ? notags(trim($data['language'])) : 'en';
  337. $publish = x($data, 'profile_publish_reg') && intval($data['profile_publish_reg']) ? 1 : 0;
  338. $netpublish = strlen(Config::get('system', 'directory')) ? $publish : 0;
  339. if ($password1 != $confirm) {
  340. throw new Exception(L10n::t('Passwords do not match. Password unchanged.'));
  341. } elseif ($password1 != '') {
  342. $password = $password1;
  343. }
  344. if ($using_invites) {
  345. if (!$invite_id) {
  346. throw new Exception(L10n::t('An invitation is required.'));
  347. }
  348. if (!dba::exists('register', ['hash' => $invite_id])) {
  349. throw new Exception(L10n::t('Invitation could not be verified.'));
  350. }
  351. }
  352. if (!x($username) || !x($email) || !x($nickname)) {
  353. if ($openid_url) {
  354. if (!Network::isUrlValid($openid_url)) {
  355. throw new Exception(L10n::t('Invalid OpenID url'));
  356. }
  357. $_SESSION['register'] = 1;
  358. $_SESSION['openid'] = $openid_url;
  359. $openid = new LightOpenID($a->get_hostname());
  360. $openid->identity = $openid_url;
  361. $openid->returnUrl = System::baseUrl() . '/openid';
  362. $openid->required = ['namePerson/friendly', 'contact/email', 'namePerson'];
  363. $openid->optional = ['namePerson/first', 'media/image/aspect11', 'media/image/default'];
  364. try {
  365. $authurl = $openid->authUrl();
  366. } catch (Exception $e) {
  367. throw new Exception(L10n::t('We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID.') . EOL . EOL . L10n::t('The error message was:') . $e->getMessage(), 0, $e);
  368. }
  369. goaway($authurl);
  370. // NOTREACHED
  371. }
  372. throw new Exception(L10n::t('Please enter the required information.'));
  373. }
  374. if (!Network::isUrlValid($openid_url)) {
  375. $openid_url = '';
  376. }
  377. $err = '';
  378. // collapse multiple spaces in name
  379. $username = preg_replace('/ +/', ' ', $username);
  380. if (mb_strlen($username) > 48) {
  381. throw new Exception(L10n::t('Please use a shorter name.'));
  382. }
  383. if (mb_strlen($username) < 3) {
  384. throw new Exception(L10n::t('Name too short.'));
  385. }
  386. // So now we are just looking for a space in the full name.
  387. $loose_reg = Config::get('system', 'no_regfullname');
  388. if (!$loose_reg) {
  389. $username = mb_convert_case($username, MB_CASE_TITLE, 'UTF-8');
  390. if (!strpos($username, ' ')) {
  391. throw new Exception(L10n::t("That doesn't appear to be your full \x28First Last\x29 name."));
  392. }
  393. }
  394. if (!Network::isEmailDomainAllowed($email)) {
  395. throw new Exception(L10n::t('Your email domain is not among those allowed on this site.'));
  396. }
  397. if (!valid_email($email) || !Network::isEmailDomainValid($email)) {
  398. throw new Exception(L10n::t('Not a valid email address.'));
  399. }
  400. if (self::isNicknameBlocked($nickname)) {
  401. throw new Exception(L10n::t('The nickname was blocked from registration by the nodes admin.'));
  402. }
  403. if (Config::get('system', 'block_extended_register', false) && dba::exists('user', ['email' => $email])) {
  404. throw new Exception(L10n::t('Cannot use that email.'));
  405. }
  406. // Disallow somebody creating an account using openid that uses the admin email address,
  407. // since openid bypasses email verification. We'll allow it if there is not yet an admin account.
  408. if (x($a->config, 'admin_email') && strlen($openid_url)) {
  409. $adminlist = explode(',', str_replace(' ', '', strtolower($a->config['admin_email'])));
  410. if (in_array(strtolower($email), $adminlist)) {
  411. throw new Exception(L10n::t('Cannot use that email.'));
  412. }
  413. }
  414. $nickname = $data['nickname'] = strtolower($nickname);
  415. if (!preg_match('/^[a-z0-9][a-z0-9\_]*$/', $nickname)) {
  416. throw new Exception(L10n::t('Your nickname can only contain a-z, 0-9 and _.'));
  417. }
  418. // Check existing and deleted accounts for this nickname.
  419. if (dba::exists('user', ['nickname' => $nickname])
  420. || dba::exists('userd', ['username' => $nickname])
  421. ) {
  422. throw new Exception(L10n::t('Nickname is already registered. Please choose another.'));
  423. }
  424. $new_password = strlen($password) ? $password : User::generateNewPassword();
  425. $new_password_encoded = self::hashPassword($new_password);
  426. $return['password'] = $new_password;
  427. $keys = Crypto::newKeypair(4096);
  428. if ($keys === false) {
  429. throw new Exception(L10n::t('SERIOUS ERROR: Generation of security keys failed.'));
  430. }
  431. $prvkey = $keys['prvkey'];
  432. $pubkey = $keys['pubkey'];
  433. // Create another keypair for signing/verifying salmon protocol messages.
  434. $sres = Crypto::newKeypair(512);
  435. $sprvkey = $sres['prvkey'];
  436. $spubkey = $sres['pubkey'];
  437. $insert_result = dba::insert('user', [
  438. 'guid' => generate_user_guid(),
  439. 'username' => $username,
  440. 'password' => $new_password_encoded,
  441. 'email' => $email,
  442. 'openid' => $openid_url,
  443. 'nickname' => $nickname,
  444. 'pubkey' => $pubkey,
  445. 'prvkey' => $prvkey,
  446. 'spubkey' => $spubkey,
  447. 'sprvkey' => $sprvkey,
  448. 'verified' => $verified,
  449. 'blocked' => $blocked,
  450. 'language' => $language,
  451. 'timezone' => 'UTC',
  452. 'register_date' => DateTimeFormat::utcNow(),
  453. 'default-location' => ''
  454. ]);
  455. if ($insert_result) {
  456. $uid = dba::lastInsertId();
  457. $user = dba::selectFirst('user', [], ['uid' => $uid]);
  458. } else {
  459. throw new Exception(L10n::t('An error occurred during registration. Please try again.'));
  460. }
  461. if (!$uid) {
  462. throw new Exception(L10n::t('An error occurred during registration. Please try again.'));
  463. }
  464. // if somebody clicked submit twice very quickly, they could end up with two accounts
  465. // due to race condition. Remove this one.
  466. $user_count = dba::count('user', ['nickname' => $nickname]);
  467. if ($user_count > 1) {
  468. dba::delete('user', ['uid' => $uid]);
  469. throw new Exception(L10n::t('Nickname is already registered. Please choose another.'));
  470. }
  471. $insert_result = dba::insert('profile', [
  472. 'uid' => $uid,
  473. 'name' => $username,
  474. 'photo' => System::baseUrl() . "/photo/profile/{$uid}.jpg",
  475. 'thumb' => System::baseUrl() . "/photo/avatar/{$uid}.jpg",
  476. 'publish' => $publish,
  477. 'is-default' => 1,
  478. 'net-publish' => $netpublish,
  479. 'profile-name' => L10n::t('default')
  480. ]);
  481. if (!$insert_result) {
  482. dba::delete('user', ['uid' => $uid]);
  483. throw new Exception(L10n::t('An error occurred creating your default profile. Please try again.'));
  484. }
  485. // Create the self contact
  486. if (!Contact::createSelfFromUserId($uid)) {
  487. dba::delete('user', ['uid' => $uid]);
  488. throw new Exception(L10n::t('An error occurred creating your self contact. Please try again.'));
  489. }
  490. // Create a group with no members. This allows somebody to use it
  491. // right away as a default group for new contacts.
  492. $def_gid = Group::create($uid, L10n::t('Friends'));
  493. if (!$def_gid) {
  494. dba::delete('user', ['uid' => $uid]);
  495. throw new Exception(L10n::t('An error occurred creating your default contact group. Please try again.'));
  496. }
  497. $fields = ['def_gid' => $def_gid];
  498. if (Config::get('system', 'newuser_private') && $def_gid) {
  499. $fields['allow_gid'] = '<' . $def_gid . '>';
  500. }
  501. dba::update('user', $fields, ['uid' => $uid]);
  502. // if we have no OpenID photo try to look up an avatar
  503. if (!strlen($photo)) {
  504. $photo = Network::lookupAvatarByEmail($email);
  505. }
  506. // unless there is no avatar-addon loaded
  507. if (strlen($photo)) {
  508. $photo_failure = false;
  509. $filename = basename($photo);
  510. $img_str = Network::fetchUrl($photo, true);
  511. // guess mimetype from headers or filename
  512. $type = Image::guessType($photo, true);
  513. $Image = new Image($img_str, $type);
  514. if ($Image->isValid()) {
  515. $Image->scaleToSquare(175);
  516. $hash = Photo::newResource();
  517. $r = Photo::store($Image, $uid, 0, $hash, $filename, L10n::t('Profile Photos'), 4);
  518. if ($r === false) {
  519. $photo_failure = true;
  520. }
  521. $Image->scaleDown(80);
  522. $r = Photo::store($Image, $uid, 0, $hash, $filename, L10n::t('Profile Photos'), 5);
  523. if ($r === false) {
  524. $photo_failure = true;
  525. }
  526. $Image->scaleDown(48);
  527. $r = Photo::store($Image, $uid, 0, $hash, $filename, L10n::t('Profile Photos'), 6);
  528. if ($r === false) {
  529. $photo_failure = true;
  530. }
  531. if (!$photo_failure) {
  532. dba::update('photo', ['profile' => 1], ['resource-id' => $hash]);
  533. }
  534. }
  535. }
  536. Addon::callHooks('register_account', $uid);
  537. $return['user'] = $user;
  538. return $return;
  539. }
  540. /**
  541. * @brief Sends pending registration confiŕmation email
  542. *
  543. * @param string $email
  544. * @param string $sitename
  545. * @param string $username
  546. * @return NULL|boolean from notification() and email() inherited
  547. */
  548. public static function sendRegisterPendingEmail($email, $sitename, $username)
  549. {
  550. $body = deindent(L10n::t('
  551. Dear %1$s,
  552. Thank you for registering at %2$s. Your account is pending for approval by the administrator.
  553. '));
  554. $body = sprintf($body, $username, $sitename);
  555. return notification([
  556. 'type' => SYSTEM_EMAIL,
  557. 'to_email' => $email,
  558. 'subject'=> L10n::t('Registration at %s', $sitename),
  559. 'body' => $body]);
  560. }
  561. /**
  562. * @brief Sends registration confirmation
  563. *
  564. * It's here as a function because the mail is sent from different parts
  565. *
  566. * @param string $email
  567. * @param string $sitename
  568. * @param string $siteurl
  569. * @param string $username
  570. * @param string $password
  571. * @return NULL|boolean from notification() and email() inherited
  572. */
  573. public static function sendRegisterOpenEmail($email, $sitename, $siteurl, $username, $password)
  574. {
  575. $preamble = deindent(L10n::t('
  576. Dear %1$s,
  577. Thank you for registering at %2$s. Your account has been created.
  578. '));
  579. $body = deindent(L10n::t('
  580. The login details are as follows:
  581. Site Location: %3$s
  582. Login Name: %1$s
  583. Password: %5$s
  584. You may change your password from your account "Settings" page after logging
  585. in.
  586. Please take a few moments to review the other account settings on that page.
  587. You may also wish to add some basic information to your default profile
  588. ' . "\x28" . 'on the "Profiles" page' . "\x29" . ' so that other people can easily find you.
  589. We recommend setting your full name, adding a profile photo,
  590. adding some profile "keywords" ' . "\x28" . 'very useful in making new friends' . "\x29" . ' - and
  591. perhaps what country you live in; if you do not wish to be more specific
  592. than that.
  593. We fully respect your right to privacy, and none of these items are necessary.
  594. If you are new and do not know anybody here, they may help
  595. you to make some new and interesting friends.
  596. If you ever want to delete your account, you can do so at %3$s/removeme
  597. Thank you and welcome to %2$s.'));
  598. $preamble = sprintf($preamble, $username, $sitename);
  599. $body = sprintf($body, $email, $sitename, $siteurl, $username, $password);
  600. return notification([
  601. 'type' => SYSTEM_EMAIL,
  602. 'to_email' => $email,
  603. 'subject'=> L10n::t('Registration details for %s', $sitename),
  604. 'preamble'=> $preamble,
  605. 'body' => $body]);
  606. }
  607. /**
  608. * @param object $uid user to remove
  609. * @return void
  610. */
  611. public static function remove($uid)
  612. {
  613. if (!$uid) {
  614. return;
  615. }
  616. logger('Removing user: ' . $uid);
  617. $user = dba::selectFirst('user', [], ['uid' => $uid]);
  618. Addon::callHooks('remove_user', $user);
  619. // save username (actually the nickname as it is guaranteed
  620. // unique), so it cannot be re-registered in the future.
  621. dba::insert('userd', ['username' => $user['nickname']]);
  622. // The user and related data will be deleted in "cron_expire_and_remove_users" (cronjobs.php)
  623. dba::update('user', ['account_removed' => true, 'account_expires_on' => DateTimeFormat::utcNow()], ['uid' => $uid]);
  624. Worker::add(PRIORITY_HIGH, "Notifier", "removeme", $uid);
  625. // Send an update to the directory
  626. Worker::add(PRIORITY_LOW, "Directory", $user['url']);
  627. if ($uid == local_user()) {
  628. unset($_SESSION['authenticated']);
  629. unset($_SESSION['uid']);
  630. goaway(System::baseUrl());
  631. }
  632. }
  633. }