use Friendica\Content\Pager;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
+use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Core\System;
use Friendica\Navigation\Notifications\ValueObject\FormattedNotify;
use Friendica\Network\HTTPException\ForbiddenException;
*/
abstract public function getNotifications();
- public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
+ public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IHandleUserSessions $userSession, array $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
- if (!Session::getLocalUser()) {
+ if (!$userSession->getLocalUserId()) {
throw new ForbiddenException($this->t('Permission denied.'));
}
use Friendica\Content\Widget;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
-use Friendica\Core\Session;
+use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Core\Theme;
use Friendica\Model;
use Friendica\Module\Contact;
* @var LocalRelationship
*/
private $localRelationship;
+ /**
+ * @var IHandleUserSessions
+ */
+ private $userSession;
- public function __construct(L10n $l10n, LocalRelationship $localRelationship, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, App\Page $page, Conversation $conversation, array $server, array $parameters = [])
+ public function __construct(L10n $l10n, LocalRelationship $localRelationship, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, App\Page $page, Conversation $conversation, IHandleUserSessions $userSession, $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$this->page = $page;
$this->conversation = $conversation;
$this->localRelationship = $localRelationship;
+ $this->userSession = $userSession;
}
protected function content(array $request = []): string
{
- if (!Session::getLocalUser()) {
+ if (!$this->userSession->getLocalUserId()) {
return Login::form($_SERVER['REQUEST_URI']);
}
// Backward compatibility: Ensure to use the public contact when the user contact is provided
// Remove by version 2022.03
- $data = Model\Contact::getPublicAndUserContactID(intval($this->parameters['id']), Session::getLocalUser());
+ $data = Model\Contact::getPublicAndUserContactID(intval($this->parameters['id']), $this->userSession->getLocalUserId());
if (empty($data)) {
throw new NotFoundException($this->t('Contact not found.'));
}
throw new NotFoundException($this->t('Contact not found.'));
}
- $localRelationship = $this->localRelationship->getForUserContact(Session::getLocalUser(), $contact['id']);
+ $localRelationship = $this->localRelationship->getForUserContact($this->userSession->getLocalUserId(), $contact['id']);
if ($localRelationship->rel === Model\Contact::SELF) {
$this->baseUrl->redirect('profile/' . $contact['nick']);
}
use Friendica\Content\Widget;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
-use Friendica\Core\Session;
+use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Database\DBA;
use Friendica\Model;
use Friendica\Module\Contact;
* @var App\Page
*/
private $page;
+ /**
+ * @var IHandleUserSessions
+ */
+ private $userSession;
- public function __construct(L10n $l10n, LocalRelationship $localRelationship, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, App\Page $page, array $server, array $parameters = [])
+ public function __construct(L10n $l10n, LocalRelationship $localRelationship, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, App\Page $page, IHandleUserSessions $userSession, $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$this->localRelationship = $localRelationship;
$this->page = $page;
+ $this->userSession = $userSession;
}
protected function content(array $request = []): string
{
- if (!Session::getLocalUser()) {
+ if (!$this->userSession->getLocalUserId()) {
return Login::form($_SERVER['REQUEST_URI']);
}
// Backward compatibility: Ensure to use the public contact when the user contact is provided
// Remove by version 2022.03
- $data = Model\Contact::getPublicAndUserContactID(intval($this->parameters['id']), Session::getLocalUser());
+ $data = Model\Contact::getPublicAndUserContactID(intval($this->parameters['id']), $this->userSession->getLocalUserId());
if (empty($data)) {
throw new NotFoundException($this->t('Contact not found.'));
}
throw new NotFoundException($this->t('Contact not found.'));
}
- $localRelationship = $this->localRelationship->getForUserContact(Session::getLocalUser(), $contact['id']);
+ $localRelationship = $this->localRelationship->getForUserContact($this->userSession->getLocalUserId(), $contact['id']);
if ($localRelationship->rel === Model\Contact::SELF) {
$this->baseUrl->redirect('profile/' . $contact['nick']);
}
use Friendica\App;
use Friendica\BaseModule;
use Friendica\Core\L10n;
-use Friendica\Core\Session;
+use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Post;
{
/** @var SystemMessages */
private $systemMessages;
+ /** @var IHandleUserSessions */
+ private $userSession;
- public function __construct(SystemMessages $systemMessages, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
+ public function __construct(SystemMessages $systemMessages, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IHandleUserSessions $userSession, array $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$this->systemMessages = $systemMessages;
+ $this->userSession = $userSession;
}
protected function post(array $request = [])
protected function content(array $request = []): string
{
- if (!Session::getLocalUser()) {
+ if (!$this->userSession->getLocalUserId()) {
throw new HTTPException\ForbiddenException();
}
return 404;
}
- if (!Post\Category::deleteFileByURIId($item['uri-id'], Session::getLocalUser(), $type, $term)) {
+ if (!Post\Category::deleteFileByURIId($item['uri-id'], $this->userSession->getLocalUserId(), $type, $term)) {
$this->systemMessages->addNotice($this->l10n->t('Item was not removed'));
return 500;
}
use Friendica\App;
use Friendica\BaseModule;
use Friendica\Core\L10n;
-use Friendica\Core\Session;
+use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Core\System;
use Friendica\Database\Database;
use Friendica\Model\Contact;
protected $dba;
/** @var ICanSendHttpRequests */
protected $httpClient;
+ /** @var IHandleUserSessions */
+ protected $userSession;
- public function __construct(App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, Database $dba, ICanSendHttpRequests $httpClient, array $server, array $parameters = [])
+ public function __construct(App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, Database $dba, ICanSendHttpRequests $httpClient, IHandleUserSessions $userSession, $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
- $this->app = $app;
- $this->dba = $dba;
- $this->httpClient = $httpClient;
+ $this->app = $app;
+ $this->dba = $dba;
+ $this->httpClient = $httpClient;
+ $this->userSession = $userSession;
}
protected function rawContent(array $request = [])
}
// OpenWebAuth
- if (Session::getLocalUser() && $owa) {
- $user = User::getById(Session::getLocalUser());
+ if ($this->userSession->getLocalUserId() && $owa) {
+ $user = User::getById($this->userSession->getLocalUserId());
// Extract the basepath
// NOTE: we need another solution because this does only work
namespace Friendica\Module;
+use Friendica\App;
use Friendica\BaseModule;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
-use Friendica\Core\Session;
+use Friendica\Core\L10n;
+use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Core\System;
use Friendica\Network\HTTPException\BadRequestException;
use Friendica\Util;
+use Friendica\Util\Profiler;
+use Psr\Log\LoggerInterface;
class ParseUrl extends BaseModule
{
+ /** @var IHandleUserSessions */
+ protected $userSession;
+
+ public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, Session\Capability\IHandleUserSessions $userSession, $server, array $parameters = [])
+ {
+ parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
+
+ $this->userSession = $userSession;
+ }
+
protected function rawContent(array $request = [])
{
- if (!Session::isAuthenticated()) {
+ if (!$this->userSession->isAuthenticated()) {
throw new \Friendica\Network\HTTPException\ForbiddenException();
}
use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
+use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Database\DBA;
use Friendica\Model\User;
use Friendica\Module\Response;
{
/** @var SystemMessages */
private $sysmsg;
+ /** @var IHandleUserSessions */
+ private $userSession;
- public function __construct(SystemMessages $sysmsg, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
+ public function __construct(SystemMessages $sysmsg, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IHandleUserSessions $userSession, $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
- $this->sysmsg = $sysmsg;
+ $this->sysmsg = $sysmsg;
+ $this->userSession = $userSession;
}
protected function post(array $request = [])
}
// check if the old password was supplied correctly before changing it to the new value
- User::getIdFromPasswordAuthentication(Session::getLocalUser(), $request['password_current']);
+ User::getIdFromPasswordAuthentication($this->userSession->getLocalUserId(), $request['password_current']);
if (strlen($request['password_current']) <= 72) {
throw new \Exception($this->l10n->t('Password does not need changing.'));
}
- $result = User::updatePassword(Session::getLocalUser(), $newpass);
+ $result = User::updatePassword($this->userSession->getLocalUserId(), $newpass);
if (!DBA::isResult($result)) {
throw new \Exception($this->l10n->t('Password update failed. Please try again.'));
}
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Core\Session\Capability\IHandleSessions;
+use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Module\Response;
use Friendica\Util\Profiler;
use PragmaRX\Google2FA\Google2FA;
protected $session;
/** @var IManagePersonalConfigValues */
protected $pConfig;
+ /** @var IHandleUserSessions */
+ protected $userSession;
- public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IManagePersonalConfigValues $pConfig, IHandleSessions $session, array $server, array $parameters = [])
+ 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 = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
- $this->session = $session;
- $this->pConfig = $pConfig;
+ $this->session = $session;
+ $this->pConfig = $pConfig;
+ $this->userSession = $userSession;
}
protected function post(array $request = [])
{
- if (!Session::getLocalUser()) {
+ if (!$this->userSession->getLocalUserId()) {
return;
}
$code = $request['verify_code'] ?? '';
- $valid = (new Google2FA())->verifyKey($this->pConfig->get(Session::getLocalUser(), '2fa', 'secret'), $code);
+ $valid = (new Google2FA())->verifyKey($this->pConfig->get($this->userSession->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 (!Session::getLocalUser()) {
+ if (!$this->userSession->getLocalUserId()) {
$this->baseUrl->redirect();
}