use Exception;
use Friendica\App;
+use Friendica\App\BaseURL;
+use Friendica\App\Mode;
+use Friendica\App\Request;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\Worker;
use Friendica\Model\Contact;
+use Friendica\Model\User\Cookie;
use Friendica\Util\Strings;
use Psr\Log\LoggerInterface;
{
/** @var IManageConfigValues */
private $config;
- /** @var App\Mode */
+ /** @var Mode */
private $mode;
- /** @var App\BaseURL */
+ /** @var BaseURL */
private $baseUrl;
/** @var L10n */
private $l10n;
private $dba;
/** @var LoggerInterface */
private $logger;
- /** @var User\Cookie */
+ /** @var Cookie */
private $cookie;
/** @var IHandleUserSessions */
private $session;
* Authentication constructor.
*
* @param IManageConfigValues $config
- * @param App\Mode $mode
- * @param App\BaseURL $baseUrl
+ * @param Mode $mode
+ * @param BaseURL $baseUrl
* @param L10n $l10n
* @param Database $dba
* @param LoggerInterface $logger
- * @param User\Cookie $cookie
+ * @param Cookie $cookie
* @param IHandleUserSessions $session
* @param IManagePersonalConfigValues $pConfig
- * @param App\Request $request
+ * @param Request $request
*/
- public function __construct(IManageConfigValues $config, App\Mode $mode, App\BaseURL $baseUrl, L10n $l10n, Database $dba, LoggerInterface $logger, User\Cookie $cookie, IHandleUserSessions $session, IManagePersonalConfigValues $pConfig, App\Request $request)
- {
+ public function __construct(
+ IManageConfigValues $config,
+ Mode $mode,
+ BaseURL $baseUrl,
+ L10n $l10n,
+ Database $dba,
+ LoggerInterface $logger,
+ Cookie $cookie,
+ IHandleUserSessions $session,
+ IManagePersonalConfigValues $pConfig,
+ Request $request
+ ) {
$this->config = $config;
$this->mode = $mode;
$this->baseUrl = $baseUrl;
/**
* Tries to auth the user from the cookie or session
*
- * @param App $a The Friendica Application context
+ * @param App $app The Friendica Application context
*
* @throws HttpException\InternalServerErrorException In case of Friendica internal exceptions
* @throws Exception In case of general exceptions (like SQL Grammar)
*/
- public function withSession(App $a)
+ public function withSession(App $app)
{
// When the "Friendica" cookie is set, take the value to authenticate and renew the cookie.
if ($this->cookie->get('uid')) {
// Do the authentication if not done by now
if (!$this->session->isAuthenticated()) {
- $this->setForUser($a, $user);
+ $this->setForUser($app, $user);
if ($this->config->get('system', 'paranoia')) {
$this->session->set('addr', $this->cookie->get('ip'));
if ($this->session->isVisitor()) {
$contact = $this->dba->selectFirst('contact', ['id'], ['id' => $this->session->get('visitor_id')]);
if ($this->dba->isResult($contact)) {
- $a->setContactId($contact['id']);
+ $app->setContactId($contact['id']);
}
}
$this->baseUrl->redirect();
}
- $this->setForUser($a, $user);
+ $this->setForUser($app, $user);
}
}
/**
* Attempts to authenticate using login/password
*
- * @param App $a The Friendica Application context
+ * @param App $app The Friendica Application context
* @param string $username
* @param string $password Clear password
* @param bool $remember Whether to set the session remember flag
* @throws HTTPException\MovedPermanentlyException
* @throws HTTPException\TemporaryRedirectException
*/
- public function withPassword(App $a, string $username, string $password, bool $remember, string $return_path = '')
+ public function withPassword(App $app, string $username, string $password, bool $remember, string $return_path = '')
{
$record = null;
$return_path = '/security/password_too_long?' . http_build_query(['return_path' => $return_path]);
}
- $this->setForUser($a, $record, true, true);
+ $this->setForUser($app, $record, true, true);
$this->baseUrl->redirect($return_path);
}
/**
* Sets the provided user's authenticated session
*
- * @param App $a The Friendica application context
+ * @param App $app The Friendica application context
* @param array $user_record The current "user" record
* @param bool $login_initial
* @param bool $interactive
* @throws HTTPException\InternalServerErrorException In case of Friendica specific exceptions
*
*/
- public function setForUser(App $a, array $user_record, bool $login_initial = false, bool $interactive = false, bool $refresh_login = true)
+ public function setForUser(App $app, array $user_record, bool $login_initial = false, bool $interactive = false, bool $refresh_login = true)
{
$my_url = $this->baseUrl . '/profile/' . $user_record['nickname'];
$this->session->set('new_member', time() < ($member_since + (60 * 60 * 24 * 14)));
if (strlen($user_record['timezone'])) {
- $a->setTimeZone($user_record['timezone']);
+ $app->setTimeZone($user_record['timezone']);
}
$contact = $this->dba->selectFirst('contact', ['id'], ['uid' => $user_record['uid'], 'self' => true]);
if ($this->dba->isResult($contact)) {
- $a->setContactId($contact['id']);
+ $app->setContactId($contact['id']);
$this->session->set('cid', $contact['id']);
}
if (Strings::compareLink($this->session->get('visitor_home') ?: '', $url)) {
return;
}
-
+
$this->session->set('my_url', $url);
$this->session->set('authenticated', 0);
-
+
$remote_contact = Contact::getByURL($url, false, ['subscribe']);
if (!empty($remote_contact['subscribe'])) {
$this->session->set('remote_comment', $remote_contact['subscribe']);