]> git.mxchange.org Git - friendica.git/blobdiff - src/Security/Authentication.php
"getStyledURL" is now public
[friendica.git] / src / Security / Authentication.php
index c38a2eb6dd24c88b5064c4a32ad845d422b59d31..91963ee399d130748b2d48df7277761f0cfe0615 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -38,6 +38,8 @@ use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
 use LightOpenID;
 use Friendica\Core\L10n;
+use Friendica\Core\Worker;
+use Friendica\Model\Contact;
 use Psr\Log\LoggerInterface;
 
 /**
@@ -228,11 +230,11 @@ class Authentication
 
                // Otherwise it's probably an openid.
                try {
-                       $openid           = new LightOpenID($this->baseUrl->getHostname());
+                       $openid           = new LightOpenID($this->baseUrl->getHost());
                        $openid->identity = $openid_url;
                        $this->session->set('openid', $openid_url);
                        $this->session->set('remember', $remember);
-                       $openid->returnUrl = $this->baseUrl->get(true) . '/openid';
+                       $openid->returnUrl = $this->baseUrl . '/openid';
                        $openid->optional  = ['namePerson/friendly', 'contact/email', 'namePerson', 'namePerson/first', 'media/image/aspect11', 'media/image/default'];
                        System::externalRedirect($openid->authUrl());
                } catch (Exception $e) {
@@ -321,19 +323,21 @@ class Authentication
         */
        public function setForUser(App $a, array $user_record, bool $login_initial = false, bool $interactive = false, bool $login_refresh = false)
        {
+               $my_url = $this->baseUrl . '/profile/' . $user_record['nickname'];
+
                $this->session->setMultiple([
                        'uid'           => $user_record['uid'],
                        'theme'         => $user_record['theme'],
                        'mobile-theme'  => $this->pConfig->get($user_record['uid'], 'system', 'mobile_theme'),
                        'authenticated' => 1,
                        'page_flags'    => $user_record['page-flags'],
-                       'my_url'        => $this->baseUrl->get() . '/profile/' . $user_record['nickname'],
-                       'my_address'    => $user_record['nickname'] . '@' . substr($this->baseUrl->get(), strpos($this->baseUrl->get(), '://') + 3),
+                       'my_url'        => $my_url,
+                       'my_address'    => $user_record['nickname'] . '@' . substr($this->baseUrl, strpos($this->baseUrl, '://') + 3),
                        'addr'          => $this->remoteAddress,
                        'nickname'      => $user_record['nickname'],
                ]);
 
-               $this->session->setVisitorsContacts();
+               $this->session->setVisitorsContacts($my_url);
 
                $member_since = strtotime($user_record['register_date']);
                $this->session->set('new_member', time() < ($member_since + (60 * 60 * 24 * 14)));
@@ -351,11 +355,16 @@ class Authentication
                $this->setXAccMgmtStatusHeader($user_record);
 
                if ($login_initial || $login_refresh) {
-                       $this->dba->update('user', ['login_date' => DateTimeFormat::utcNow()], ['uid' => $user_record['uid']]);
+                       $this->dba->update('user', ['last-activity' => DateTimeFormat::utcNow('Y-m-d'), 'login_date' => DateTimeFormat::utcNow()], ['uid' => $user_record['uid']]);
 
                        // Set the login date for all identities of the user
-                       $this->dba->update('user', ['login_date' => DateTimeFormat::utcNow()],
+                       $this->dba->update('user', ['last-activity' => DateTimeFormat::utcNow('Y-m-d'), 'login_date' => DateTimeFormat::utcNow()],
                                ['parent-uid' => $user_record['uid'], 'account_removed' => false]);
+
+                       // Regularly update suggestions
+                       if (Contact\Relation::areSuggestionsOutdated($user_record['uid'])) {
+                               Worker::add(Worker::PRIORITY_MEDIUM, 'UpdateSuggestions', $user_record['uid']);
+                       }
                }
 
                if ($login_initial) {
@@ -385,9 +394,6 @@ class Authentication
                        }
                }
 
-               $a->setLoggedInUserId($user_record['uid']);
-               $a->setLoggedInUserNickname($user_record['nickname']);
-
                if ($login_initial) {
                        Hook::callAll('logged_in', $user_record);
                }