<?php
/**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
use Friendica\Util\Strings;
use LightOpenID;
use Friendica\Core\L10n;
+use Friendica\Core\Logger;
use Psr\Log\LoggerInterface;
/**
{
$record = null;
- $addon_auth = [
- 'username' => $username,
- 'password' => $password,
- 'authenticated' => 0,
- 'user_record' => null
- ];
-
- /*
- * An addon indicates successful login by setting 'authenticated' to non-zero value and returning a user record
- * Addons should never set 'authenticated' except to indicate success - as hooks may be chained
- * and later addons should not interfere with an earlier one that succeeded.
- */
- Hook::callAll('authenticate', $addon_auth);
-
try {
- if ($addon_auth['authenticated']) {
- $record = $addon_auth['user_record'];
-
- if (empty($record)) {
- throw new Exception($this->l10n->t('Login failed.'));
- }
- } else {
- $record = $this->dba->selectFirst(
- 'user',
- [],
- ['uid' => User::getIdFromPasswordAuthentication($username, $password)]
- );
- }
+ $record = $this->dba->selectFirst(
+ 'user',
+ [],
+ ['uid' => User::getIdFromPasswordAuthentication($username, $password)]
+ );
} catch (Exception $e) {
$this->logger->warning('authenticate: failed login attempt', ['action' => 'login', 'username' => Strings::escapeTags($username), 'ip' => $_SERVER['REMOTE_ADDR']]);
notice($this->l10n->t('Login failed. Please check your credentials.'));
$this->dba->update('user', ['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()],
- ['parent-uid' => $masterUid, 'account_removed' => false]);
+ if (!empty($masterUid)) {
+ $this->dba->update('user', ['login_date' => DateTimeFormat::utcNow()],
+ ['parent-uid' => $masterUid, 'account_removed' => false]);
+ }
}
if ($login_initial) {