X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FSecurity%2FAuthentication.php;h=91963ee399d130748b2d48df7277761f0cfe0615;hb=d2429b109601ab875f0ed0802b349edee07fba06;hp=d1e64534c6bb176aba00d329255d32faf896ec54;hpb=067f06b1660db7a6b29dddaf6896649474e27fff;p=friendica.git diff --git a/src/Security/Authentication.php b/src/Security/Authentication.php index d1e64534c6..91963ee399 100644 --- a/src/Security/Authentication.php +++ b/src/Security/Authentication.php @@ -1,6 +1,6 @@ config = $config; $this->mode = $mode; @@ -223,21 +224,21 @@ class Authentication // if it's an email address or doesn't resolve to a URL, fail. if ($noid || strpos($openid_url, '@') || !Network::isUrlValid($openid_url)) { - notice($this->l10n->t('Login failed.')); + DI::sysmsg()->addNotice($this->l10n->t('Login failed.')); $this->baseUrl->redirect(); } // 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) { - notice($this->l10n->t('We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID.') . '

' . $this->l10n->t('The error message was:') . ' ' . $e->getMessage()); + DI::sysmsg()->addNotice($this->l10n->t('We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID.') . '

' . $this->l10n->t('The error message was:') . ' ' . $e->getMessage()); } } @@ -268,7 +269,7 @@ class Authentication ); } catch (Exception $e) { $this->logger->warning('authenticate: failed login attempt', ['action' => 'login', 'username' => $username, 'ip' => $this->remoteAddress]); - notice($this->l10n->t('Login failed. Please check your credentials.')); + DI::sysmsg()->addNotice($this->l10n->t('Login failed. Please check your credentials.')); $this->baseUrl->redirect(); } @@ -291,8 +292,14 @@ class Authentication $this->dba->update('user', ['openid' => $openid_identity, 'openidserver' => $openid_server], ['uid' => $record['uid']]); } - $this->setForUser($a, $record, true, true); + /** + * @see User::getPasswordRegExp() + */ + if (PASSWORD_DEFAULT === PASSWORD_BCRYPT && strlen($password) > 72) { + $return_path = '/security/password_too_long?' . http_build_query(['return_path' => $return_path]); + } + $this->setForUser($a, $record, true, true); $this->baseUrl->redirect($return_path); } @@ -316,18 +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'], ]); - 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))); @@ -345,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) { @@ -373,15 +388,12 @@ class Authentication if ($interactive) { if ($user_record['login_date'] <= DBA::NULL_DATETIME) { - info($this->l10n->t('Welcome %s', $user_record['username'])); - info($this->l10n->t('Please upload a profile photo.')); + DI::sysmsg()->addInfo($this->l10n->t('Welcome %s', $user_record['username'])); + DI::sysmsg()->addInfo($this->l10n->t('Please upload a profile photo.')); $this->baseUrl->redirect('settings/profile/photo/new'); } } - $a->setLoggedInUserId($user_record['uid']); - $a->setLoggedInUserNickname($user_record['nickname']); - if ($login_initial) { Hook::callAll('logged_in', $user_record); }