use Friendica\App\BaseURL;
use Friendica\Capabilities\ICanCreateResponses;
use Friendica\Core\Config\Factory\Config;
-use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Module\Maintenance;
use Friendica\Security\Authentication;
*/
private $pConfig;
- /**
- * @var IHandleSessions
- */
- private $session;
-
/**
* @var IHandleUserSessions
*/
- private $userSession;
+ private $session;
/**
* Set the user ID
public function isLoggedIn(): bool
{
- return $this->userSession->getLocalUserId() && $this->user_id && ($this->user_id == $this->userSession->getLocalUserId());
+ return $this->session->getLocalUserId() && $this->user_id && ($this->user_id == $this->session->getLocalUserId());
}
/**
$adminlist = explode(',', str_replace(' ', '', $admin_email));
- return $this->userSession->getLocalUserId() && $admin_email && $this->database->exists('user', ['uid' => $this->getLoggedInUserId(), 'email' => $adminlist]);
+ return $this->session->getLocalUserId() && $admin_email && $this->database->exists('user', ['uid' => $this->getLoggedInUserId(), 'email' => $adminlist]);
}
/**
* @param L10n $l10n The translator instance
* @param App\Arguments $args The Friendica Arguments of the call
* @param IManagePersonalConfigValues $pConfig Personal configuration
- * @param IHandleSessions $session The Session handler
- */
- public function __construct(Database $database, IManageConfigValues $config, App\Mode $mode, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args, IManagePersonalConfigValues $pConfig, IHandleSessions $session, IHandleUserSessions $userSession)
- {
- $this->database = $database;
- $this->config = $config;
- $this->mode = $mode;
- $this->baseURL = $baseURL;
- $this->profiler = $profiler;
- $this->logger = $logger;
- $this->l10n = $l10n;
- $this->args = $args;
- $this->pConfig = $pConfig;
- $this->session = $session;
- $this->userSession = $userSession;
+ * @param IHandleUserSessions $sessions The (User)Session handler
+ */
+ public function __construct(Database $database, IManageConfigValues $config, App\Mode $mode, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args, IManagePersonalConfigValues $pConfig, IHandleUserSessions $sessions)
+ {
+ $this->database = $database;
+ $this->config = $config;
+ $this->mode = $mode;
+ $this->baseURL = $baseURL;
+ $this->profiler = $profiler;
+ $this->logger = $logger;
+ $this->l10n = $l10n;
+ $this->args = $args;
+ $this->pConfig = $pConfig;
+ $this->session = $sessions;
$this->load();
}
$page_theme = null;
// Find the theme that belongs to the user whose stuff we are looking at
- if (!empty($this->profile_owner) && ($this->profile_owner != $this->userSession->getLocalUserId())) {
+ if (!empty($this->profile_owner) && ($this->profile_owner != $this->session->getLocalUserId())) {
// Allow folks to override user themes and always use their own on their own site.
// This works only if the user is on the same server
$user = $this->database->selectFirst('user', ['theme'], ['uid' => $this->profile_owner]);
- if ($this->database->isResult($user) && !$this->userSession->getLocalUserId()) {
+ if ($this->database->isResult($user) && !$this->session->getLocalUserId()) {
$page_theme = $user['theme'];
}
}
$page_mobile_theme = null;
// Find the theme that belongs to the user whose stuff we are looking at
- if (!empty($this->profile_owner) && ($this->profile_owner != $this->userSession->getLocalUserId())) {
+ if (!empty($this->profile_owner) && ($this->profile_owner != $this->session->getLocalUserId())) {
// Allow folks to override user themes and always use their own on their own site.
// This works only if the user is on the same server
- if (!$this->userSession->getLocalUserId()) {
+ if (!$this->session->getLocalUserId()) {
$page_mobile_theme = $this->pConfig->get($this->profile_owner, 'system', 'mobile-theme');
}
}
}
// ZRL
- if (!empty($_GET['zrl']) && $this->mode->isNormal() && !$this->mode->isBackend() && !$this->userSession->getLocalUserId()) {
+ if (!empty($_GET['zrl']) && $this->mode->isNormal() && !$this->mode->isBackend() && !$this->session->getLocalUserId()) {
// Only continue when the given profile link seems valid
// Valid profile links contain a path with "/profile/" and no query parameters
if ((parse_url($_GET['zrl'], PHP_URL_QUERY) == '') &&
$response = $module->run($input);
$this->profiler->set(microtime(true) - $timestamp, 'content');
if ($response->getHeaderLine(ICanCreateResponses::X_HEADER) === ICanCreateResponses::TYPE_HTML) {
- $page->run($this, $this->baseURL, $this->args, $this->mode, $response, $this->l10n, $this->profiler, $this->config, $pconfig, $this->userSession->getLocalUserId());
+ $page->run($this, $this->baseURL, $this->args, $this->mode, $response, $this->l10n, $this->profiler, $this->config, $pconfig, $this->session->getLocalUserId());
} else {
$page->exit($response);
}
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
-use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Core\Theme;
use Friendica\Database\DBA;
private $page;
/** @var App\Mode */
private $mode;
- /** @var IHandleSessions */
- private $session;
/** @var IHandleUserSessions */
- private $userSession;
+ private $session;
- public function __construct(LoggerInterface $logger, Profiler $profiler, Activity $activity, L10n $l10n, Item $item, Arguments $args, BaseURL $baseURL, IManageConfigValues $config, IManagePersonalConfigValues $pConfig, App\Page $page, App\Mode $mode, App $app, IHandleSessions $session, IHandleUserSessions $userSession)
+ public function __construct(LoggerInterface $logger, Profiler $profiler, Activity $activity, L10n $l10n, Item $item, Arguments $args, BaseURL $baseURL, IManageConfigValues $config, IManagePersonalConfigValues $pConfig, App\Page $page, App\Mode $mode, App $app, IHandleUserSessions $session)
{
- $this->activity = $activity;
- $this->item = $item;
- $this->config = $config;
- $this->mode = $mode;
- $this->baseURL = $baseURL;
- $this->profiler = $profiler;
- $this->logger = $logger;
- $this->l10n = $l10n;
- $this->args = $args;
- $this->pConfig = $pConfig;
- $this->page = $page;
- $this->app = $app;
- $this->session = $session;
- $this->userSession = $userSession;
+ $this->activity = $activity;
+ $this->item = $item;
+ $this->config = $config;
+ $this->mode = $mode;
+ $this->baseURL = $baseURL;
+ $this->profiler = $profiler;
+ $this->logger = $logger;
+ $this->l10n = $l10n;
+ $this->args = $args;
+ $this->pConfig = $pConfig;
+ $this->page = $page;
+ $this->app = $app;
+ $this->session = $session;
}
/**
continue;
}
- if ($this->userSession->getPublicContactId() == $activity['author-id']) {
+ if ($this->session->getPublicContactId() == $activity['author-id']) {
$conv_responses[$mode][$activity['thr-parent-id']]['self'] = 1;
}
$x['bang'] = $x['bang'] ?? '';
$x['visitor'] = $x['visitor'] ?? 'block';
$x['is_owner'] = $x['is_owner'] ?? true;
- $x['profile_uid'] = $x['profile_uid'] ?? $this->userSession->getLocalUserId();
+ $x['profile_uid'] = $x['profile_uid'] ?? $this->session->getLocalUserId();
$geotag = !empty($x['allow_location']) ? Renderer::replaceMacros(Renderer::getMarkupTemplate('jot_geotag.tpl'), []) : '';
'$title' => $x['title'] ?? '',
'$placeholdertitle' => $this->l10n->t('Set title'),
'$category' => $x['category'] ?? '',
- '$placeholdercategory' => Feature::isEnabled($this->userSession->getLocalUserId(), 'categories') ? $this->l10n->t("Categories \x28comma-separated list\x29") : '',
+ '$placeholdercategory' => Feature::isEnabled($this->session->getLocalUserId(), 'categories') ? $this->l10n->t("Categories \x28comma-separated list\x29") : '',
'$scheduled_at' => Temporal::getDateTimeField(
new \DateTime(),
new \DateTime('now + 6 months'),
'$browser' => $this->l10n->t('Browser'),
'$compose_link_title' => $this->l10n->t('Open Compose page'),
- '$always_open_compose' => $this->pConfig->get($this->userSession->getLocalUserId(), 'frio', 'always_open_compose', false),
+ '$always_open_compose' => $this->pConfig->get($this->session->getLocalUserId(), 'frio', 'always_open_compose', false),
]);
$this->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css'));
$this->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css'));
- $ssl_state = (bool)$this->userSession->getLocalUserId();
+ $ssl_state = (bool)$this->session->getLocalUserId();
$live_update_div = '';
}
}
} elseif ($mode === 'notes') {
- $items = $this->addChildren($items, false, $order, $this->userSession->getLocalUserId(), $mode);
+ $items = $this->addChildren($items, false, $order, $this->session->getLocalUserId(), $mode);
if (!$update) {
$live_update_div = '<div id="live-notes"></div>' . "\r\n"
- . "<script> var profile_uid = " . $this->userSession->getLocalUserId()
+ . "<script> var profile_uid = " . $this->session->getLocalUserId()
. "; var netargs = '/?f='; </script>\r\n";
}
} elseif ($mode === 'display') {
if (!$update) {
$live_update_div = '<div id="live-display"></div>' . "\r\n"
- . "<script> var profile_uid = " . $this->session->get('uid', 0) . ";"
+ . "<script> var profile_uid = " . $this->session->getLocalUserId() ?? 0 . ";"
. "</script>";
}
} elseif ($mode === 'community') {
$live_update_div = '<div id="live-search"></div>' . "\r\n";
}
- $page_dropping = $this->userSession->getLocalUserId() && $this->userSession->getLocalUserId() == $uid;
+ $page_dropping = $this->session->getLocalUserId() && $this->session->getLocalUserId() == $uid;
if (!$update) {
$_SESSION['return_path'] = $this->args->getQueryString();
'announce' => [],
];
- if ($this->pConfig->get($this->userSession->getLocalUserId(), 'system', 'hide_dislike')) {
+ if ($this->pConfig->get($this->session->getLocalUserId(), 'system', 'hide_dislike')) {
unset($conv_responses['dislike']);
}
$writable = $items[0]['writable'] || ($items[0]['uid'] == 0) && in_array($items[0]['network'], Protocol::FEDERATED);
}
- if (!$this->userSession->getLocalUserId()) {
+ if (!$this->session->getLocalUserId()) {
$writable = false;
}
$threadsid++;
// prevent private email from leaking.
- if ($item['network'] === Protocol::MAIL && $this->userSession->getLocalUserId() != $item['uid']) {
+ if ($item['network'] === Protocol::MAIL && $this->session->getLocalUserId() != $item['uid']) {
continue;
}
'announce' => null,
];
- if ($this->pConfig->get($this->userSession->getLocalUserId(), 'system', 'hide_dislike')) {
+ if ($this->pConfig->get($this->session->getLocalUserId(), 'system', 'hide_dislike')) {
unset($likebuttons['dislike']);
}
$body_html = ItemModel::prepareBody($item, true, $preview);
- [$categories, $folders] = $this->item->determineCategoriesTerms($item, $this->userSession->getLocalUserId());
+ [$categories, $folders] = $this->item->determineCategoriesTerms($item, $this->session->getLocalUserId());
if (!empty($item['title'])) {
$title = $item['title'];
- } elseif (!empty($item['content-warning']) && $this->pConfig->get($this->userSession->getLocalUserId(), 'system', 'disable_cw', false)) {
+ } elseif (!empty($item['content-warning']) && $this->pConfig->get($this->session->getLocalUserId(), 'system', 'disable_cw', false)) {
$title = ucfirst($item['content-warning']);
} else {
$title = '';
$this->builtinActivityPuller($item, $conv_responses);
// Only add what is visible
- if ($item['network'] === Protocol::MAIL && $this->userSession->getLocalUserId() != $item['uid']) {
+ if ($item['network'] === Protocol::MAIL && $this->session->getLocalUserId() != $item['uid']) {
continue;
}
private function getBlocklist(): array
{
- if (!$this->userSession->getLocalUserId()) {
+ if (!$this->session->getLocalUserId()) {
return [];
}
- $str_blocked = str_replace(["\n", "\r"], ",", $this->pConfig->get($this->userSession->getLocalUserId(), 'system', 'blocked'));
+ $str_blocked = str_replace(["\n", "\r"], ",", $this->pConfig->get($this->session->getLocalUserId(), 'system', 'blocked'));
if (empty($str_blocked)) {
return [];
}
$row['direction'] = ['direction' => 4, 'title' => $this->l10n->t('You subscribed to one or more tags in this post.')];
break;
case ItemModel::PR_ANNOUNCEMENT:
- if (!empty($row['causer-id']) && $this->pConfig->get($this->userSession->getLocalUserId(), 'system', 'display_resharer')) {
+ if (!empty($row['causer-id']) && $this->pConfig->get($this->session->getLocalUserId(), 'system', 'display_resharer')) {
$row['owner-id'] = $row['causer-id'];
$row['owner-link'] = $row['causer-link'];
$row['owner-avatar'] = $row['causer-avatar'];
$parents[$i]['children'] = $this->sortItemChildren($parents[$i]['children']);
}
- if (!$this->pConfig->get($this->userSession->getLocalUserId(), 'system', 'no_smart_threading', 0)) {
+ if (!$this->pConfig->get($this->session->getLocalUserId(), 'system', 'no_smart_threading', 0)) {
foreach ($parents as $i => $parent) {
$parents[$i] = $this->smartFlattenConversation($parent);
}
namespace Friendica\Core\Session\Capability;
/**
- * Handles user infos based on session infos
+ * This interface handles UserSessions, which is directly extended from the global Session interface
*/
-interface IHandleUserSessions
+interface IHandleUserSessions extends IHandleSessions
{
/**
* Returns the user id of locally logged-in user or false.
/**
* Set the session variable that contains the contact IDs for the visitor's contact URL
- *
- * @param string $url Contact URL
*/
public function setVisitorsContacts();
}
* @param LoggerInterface $logger
* @param Profiler $profiler
* @param array $server
- *
- * @return IHandleSessions
*/
- public function createSession(App\Mode $mode, App\BaseURL $baseURL, IManageConfigValues $config, Database $dba, Cache $cacheFactory, LoggerInterface $logger, Profiler $profiler, array $server = [])
+ public function createSession(App\Mode $mode, App\BaseURL $baseURL, IManageConfigValues $config, Database $dba, Cache $cacheFactory, LoggerInterface $logger, Profiler $profiler, array $server = []): IHandleSessions
{
$profiler->startRecording('session');
$session = null;
use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Model\Contact;
+/**
+ * This class handles user sessions, which is directly extended from regular session
+ */
class UserSession implements IHandleUserSessions
{
/** @var IHandleSessions */
{
$this->session->set('submanage', $managed_uid);
}
+
+ /** {@inheritDoc} */
+ public function start(): IHandleSessions
+ {
+ return $this;
+ }
+
+ /** {@inheritDoc} */
+ public function exists(string $name): bool
+ {
+ return $this->session->exists($name);
+ }
+
+ /** {@inheritDoc} */
+ public function get(string $name, $defaults = null)
+ {
+ return $this->session->get($name, $defaults);
+ }
+
+ /** {@inheritDoc} */
+ public function pop(string $name, $defaults = null)
+ {
+ return $this->session->pop($name, $defaults);
+ }
+
+ /** {@inheritDoc} */
+ public function set(string $name, $value)
+ {
+ $this->session->set($name, $value);
+ }
+
+ /** {@inheritDoc} */
+ public function setMultiple(array $values)
+ {
+ $this->session->setMultiple($values);
+ }
+
+ /** {@inheritDoc} */
+ public function remove(string $name)
+ {
+ $this->session->remove($name);
+ }
+
+ /** {@inheritDoc} */
+ public function clear()
+ {
+ $this->session->clear();
+ }
}
namespace Friendica;
use Dice\Dice;
+use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Navigation\SystemMessages;
use Psr\Log\LoggerInterface;
return self::$dice->create(Core\Worker\Repository\Process::class);
}
- /**
- * @return Core\Session\Capability\IHandleSessions
- */
- public static function session()
+ public static function session(): IHandleSessions
{
return self::$dice->create(Core\Session\Capability\IHandleSessions::class);
}
use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
-use Friendica\Core\Session\Capability\IHandleSessions;
+use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\DI;
use Friendica\Module\Register;
use Friendica\Module\Response;
/** @var IManageConfigValues */
private $config;
- /** @var IHandleSessions */
+ /** @var IHandleUserSessions */
private $session;
- public function __construct(Authentication $auth, IManageConfigValues $config, IHandleSessions $session, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
+ public function __construct(Authentication $auth, IManageConfigValues $config, IHandleUserSessions $session, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
{
$return_path = $request['return_path'] ?? $this->session->pop('return_path', '') ;
- if (DI::userSession()->getLocalUserId()) {
+ if ($this->session->getLocalUserId()) {
$this->baseUrl->redirect($return_path);
}
use Friendica\Core\Cache\Capability\ICanCache;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
-use Friendica\Core\Session\Capability\IHandleSessions;
+use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Profile;
protected $cache;
/** @var Cookie */
protected $cookie;
- /** @var IHandleSessions */
+ /** @var IHandleUserSessions
+ */
protected $session;
- public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, ICanCache $cache, Cookie $cookie, IHandleSessions $session, array $server, array $parameters = [])
+ public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, ICanCache $cache, Cookie $cookie, IHandleUserSessions $session, array $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
protected function rawContent(array $request = [])
{
$visitor_home = null;
- if (DI::userSession()->getRemoteUserId()) {
+ if ($this->session->getRemoteUserId()) {
$visitor_home = Profile::getMyURL();
$this->cache->delete('zrlInit:' . $visitor_home);
}
use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
-use Friendica\Core\Session\Capability\IHandleSessions;
+use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\DI;
use Friendica\Model\User;
use Friendica\Module\Response;
*/
class Recovery extends BaseModule
{
- /** @var IHandleSessions */
+ /** @var IHandleUserSessions */
protected $session;
/** @var App */
protected $app;
/** @var Authentication */
protected $auth;
- public function __construct(App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, Authentication $auth, IHandleSessions $session, array $server, array $parameters = [])
+ public function __construct(App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, Authentication $auth, IHandleUserSessions $session, array $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
protected function post(array $request = [])
{
- if (!DI::userSession()->getLocalUserId()) {
+ if (!$this->session->getLocalUserId()) {
return;
}
$recovery_code = $_POST['recovery_code'] ?? '';
- if (RecoveryCode::existsForUser(DI::userSession()->getLocalUserId(), $recovery_code)) {
- RecoveryCode::markUsedForUser(DI::userSession()->getLocalUserId(), $recovery_code);
+ if (RecoveryCode::existsForUser($this->session->getLocalUserId(), $recovery_code)) {
+ RecoveryCode::markUsedForUser($this->session->getLocalUserId(), $recovery_code);
$this->session->set('2fa', true);
- DI::sysmsg()->addInfo($this->t('Remaining recovery codes: %d', RecoveryCode::countValidForUser(DI::userSession()->getLocalUserId())));
+ DI::sysmsg()->addInfo($this->t('Remaining recovery codes: %d', RecoveryCode::countValidForUser($this->session->getLocalUserId())));
$this->auth->setForUser($this->app, User::getById($this->app->getLoggedInUserId()), true, true);
protected function content(array $request = []): string
{
- if (!DI::userSession()->getLocalUserId()) {
+ if (!$this->session->getLocalUserId()) {
$this->baseUrl->redirect();
}
use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
-use Friendica\Core\Session\Capability\IHandleSessions;
+use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\DI;
use Friendica\Model\User\Cookie;
use Friendica\Module\Response;
-use Friendica\Network\HTTPException\NotFoundException;
use Friendica\Util\Profiler;
use Friendica\Security\TwoFactor;
use Psr\Log\LoggerInterface;
{
protected $errors = [];
- /** @var IHandleSessions */
+ /** @var IHandleUserSessions */
protected $session;
/** @var Cookie */
protected $cookie;
/** @var TwoFactor\Repository\TrustedBrowser */
protected $trustedBrowserRepository;
- public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, IHandleSessions $session, Cookie $cookie, TwoFactor\Repository\TrustedBrowser $trustedBrowserRepository, Profiler $profiler, Response $response, array $server, array $parameters = [])
+ public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, IHandleUserSessions $session, Cookie $cookie, TwoFactor\Repository\TrustedBrowser $trustedBrowserRepository, Profiler $profiler, Response $response, array $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
protected function post(array $request = [])
{
- if (!DI::userSession()->getLocalUserId() || !($this->cookie->get('2fa_cookie_hash'))) {
+ if (!$this->session->getLocalUserId() || !($this->cookie->get('2fa_cookie_hash'))) {
return;
}
$this->baseUrl->redirect();
break;
case 'sign_out':
- $this->trustedBrowserRepository->removeForUser(DI::userSession()->getLocalUserId(), $this->cookie->get('2fa_cookie_hash'));
+ $this->trustedBrowserRepository->removeForUser($this->session->getLocalUserId(), $this->cookie->get('2fa_cookie_hash'));
$this->cookie->clear();
$this->session->clear();
protected function content(array $request = []): string
{
- if (!DI::userSession()->getLocalUserId() || !($this->cookie->get('2fa_cookie_hash'))) {
+ if (!$this->session->getLocalUserId() || !($this->cookie->get('2fa_cookie_hash'))) {
$this->baseUrl->redirect();
}
use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
-use Friendica\Core\Session\Capability\IHandleSessions;
+use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\DI;
use Friendica\Model\User;
use Friendica\Model\User\Cookie;
protected $app;
/** @var Authentication */
protected $auth;
- /** @var IHandleSessions */
+ /** @var IHandleUserSessions */
protected $session;
/** @var Cookie */
protected $cookie;
/** @var TwoFactor\Repository\TrustedBrowser */
protected $trustedBrowserRepository;
- public function __construct(App $app, Authentication $auth, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, IHandleSessions $session, Cookie $cookie, TwoFactor\Factory\TrustedBrowser $trustedBrowserFactory, TwoFactor\Repository\TrustedBrowser $trustedBrowserRepositoy, Response $response, array $server, array $parameters = [])
+ public function __construct(App $app, Authentication $auth, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, IHandleUserSessions $session, Cookie $cookie, TwoFactor\Factory\TrustedBrowser $trustedBrowserFactory, TwoFactor\Repository\TrustedBrowser $trustedBrowserRepositoy, Response $response, array $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
protected function post(array $request = [])
{
- if (!DI::userSession()->getLocalUserId() || !$this->session->get('2fa')) {
+ if (!$this->session->getLocalUserId() || !$this->session->get('2fa')) {
$this->logger->info('Invalid call', ['request' => $request]);
return;
}
switch ($action) {
case 'trust':
case 'dont_trust':
- $trustedBrowser = $this->trustedBrowserFactory->createForUserWithUserAgent(DI::userSession()->getLocalUserId(), $this->server['HTTP_USER_AGENT'], $action === 'trust');
+ $trustedBrowser = $this->trustedBrowserFactory->createForUserWithUserAgent($this->session->getLocalUserId(), $this->server['HTTP_USER_AGENT'], $action === 'trust');
try {
$this->trustedBrowserRepository->save($trustedBrowser);
protected function content(array $request = []): string
{
- if (!DI::userSession()->getLocalUserId() || !$this->session->get('2fa')) {
+ if (!$this->session->getLocalUserId() || !$this->session->get('2fa')) {
$this->baseUrl->redirect();
}
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Renderer;
-use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Module\Response;
use Friendica\Util\Profiler;
{
protected $errors = [];
- /** @var IHandleSessions */
- protected $session;
/** @var IManagePersonalConfigValues */
protected $pConfig;
/** @var IHandleUserSessions */
- protected $userSession;
+ protected $session;
- public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IManagePersonalConfigValues $pConfig, IHandleSessions $session, IHandleUserSessions $userSession, $server, array $parameters = [])
+ public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IManagePersonalConfigValues $pConfig, IHandleUserSessions $session, $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$this->session = $session;
$this->pConfig = $pConfig;
- $this->userSession = $userSession;
}
protected function post(array $request = [])
{
- if (!$this->userSession->getLocalUserId()) {
+ if (!$this->session->getLocalUserId()) {
return;
}
$code = $request['verify_code'] ?? '';
- $valid = (new Google2FA())->verifyKey($this->pConfig->get($this->userSession->getLocalUserId(), '2fa', 'secret'), $code);
+ $valid = (new Google2FA())->verifyKey($this->pConfig->get($this->session->getLocalUserId(), '2fa', 'secret'), $code);
// The same code can't be used twice even if it's valid
if ($valid && $this->session->get('2fa') !== $code) {
protected function content(array $request = []): string
{
- if (!$this->userSession->getLocalUserId()) {
+ if (!$this->session->getLocalUserId()) {
$this->baseUrl->redirect();
}
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Protocol;
-use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Database\Database;
use Friendica\Model\Contact;
private $l10n;
/** @var IManagePersonalConfigValues */
private $pConfig;
- /** @var IHandleSessions */
- private $session;
/** @var IHandleUserSessions */
- private $userSession;
+ private $session;
/** @var string */
private $nick;
- public function __construct(LoggerInterface $logger, Database $dba, BaseURL $baseUrl, L10n $l10n, App $app, IManagePersonalConfigValues $pConfig, IHandleSessions $session, IHandleUserSessions $userSession)
+ public function __construct(LoggerInterface $logger, Database $dba, BaseURL $baseUrl, L10n $l10n, App $app, IManagePersonalConfigValues $pConfig, IHandleUserSessions $session)
{
parent::__construct($logger);
- $this->dba = $dba;
- $this->baseUrl = $baseUrl;
- $this->l10n = $l10n;
- $this->pConfig = $pConfig;
- $this->session = $session;
- $this->userSession = $userSession;
- $this->nick = $app->getLoggedInUserNickname() ?? '';
+ $this->dba = $dba;
+ $this->baseUrl = $baseUrl;
+ $this->l10n = $l10n;
+ $this->pConfig = $pConfig;
+ $this->session = $session;
+ $this->nick = $app->getLoggedInUserNickname() ?? '';
}
/**
LEFT JOIN `contact` AS `sugggest-contact` ON `intro`.`suggest-cid` = `sugggest-contact`.`id`
WHERE `intro`.`uid` = ? $sql_extra
LIMIT ?, ?",
- $_SESSION['uid'],
+ $this->session->getLocalUserId(),
$start,
$limit
);
'url' => $intro['furl'],
'zrl' => Contact::magicLink($intro['furl']),
'hidden' => $intro['hidden'] == 1,
- 'post_newfriend' => (intval($this->pConfig->get($this->userSession->getLocalUserId(), 'system', 'post_newfriend')) ? '1' : 0),
+ 'post_newfriend' => (intval($this->pConfig->get($this->session->getLocalUserId(), 'system', 'post_newfriend')) ? '1' : 0),
'note' => $intro['note'],
'request' => $intro['frequest'] . '?addr=' . $return_addr]);
'label' => (($intro['network'] !== Protocol::OSTATUS) ? 'friend_request' : 'follower'),
'str_type' => (($intro['network'] !== Protocol::OSTATUS) ? $this->l10n->t('Friend/Connect Request') : $this->l10n->t('New Follower')),
'dfrn_id' => $intro['issued-id'],
- 'uid' => $this->session->get('uid'),
+ 'uid' => $this->session->getLocalUserId(),
'intro_id' => $intro['intro_id'],
'contact_id' => $intro['contact-id'],
'photo' => Contact::getPhoto($intro),
'about' => BBCode::convert($intro['about'], false),
'keywords' => $intro['keywords'],
'hidden' => $intro['hidden'] == 1,
- 'post_newfriend' => (intval($this->pConfig->get($this->userSession->getLocalUserId(), 'system', 'post_newfriend')) ? '1' : 0),
+ 'post_newfriend' => (intval($this->pConfig->get($this->session->getLocalUserId(), 'system', 'post_newfriend')) ? '1' : 0),
'url' => $intro['url'],
'zrl' => Contact::magicLink($intro['url']),
'addr' => $intro['addr'],
}
}
} catch (Exception $e) {
- $this->logger->warning('Select failed.', ['uid' => $_SESSION['uid'], 'exception' => $e]);
+ $this->logger->warning('Select failed.', ['uid' => $this->session->getLocalUserId(), 'exception' => $e]);
}
return $formattedIntroductions;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Hook;
-use Friendica\Core\Session\Capability\IHandleSessions;
+use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Core\System;
use Friendica\Database\Database;
use Friendica\Database\DBA;
private $logger;
/** @var User\Cookie */
private $cookie;
- /** @var IHandleSessions */
+ /** @var IHandleUserSessions */
private $session;
/** @var IManagePersonalConfigValues */
private $pConfig;
* @param Database $dba
* @param LoggerInterface $logger
* @param User\Cookie $cookie
- * @param IHandleSessions $session
+ * @param IHandleUserSessions $session
* @param IManagePersonalConfigValues $pConfig
* @param App\Request $request
*/
- public function __construct(IManageConfigValues $config, App\Mode $mode, App\BaseURL $baseUrl, L10n $l10n, Database $dba, LoggerInterface $logger, User\Cookie $cookie, IHandleSessions $session, IManagePersonalConfigValues $pConfig, App\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)
{
$this->config = $config;
$this->mode = $mode;
'my_url' => $this->baseUrl->get() . '/profile/' . $user_record['nickname'],
'my_address' => $user_record['nickname'] . '@' . substr($this->baseUrl->get(), strpos($this->baseUrl->get(), '://') + 3),
'addr' => $this->remoteAddress,
+ 'nickname' => $user_record['nickname'],
]);
- DI::userSession()->setVisitorsContacts();
+ $this->session->setVisitorsContacts();
$member_since = strtotime($user_record['register_date']);
$this->session->set('new_member', time() < ($member_since + (60 * 60 * 24 * 14)));