1
0
Fork 0

UserSession class [5] - Refactor src/Module/ files with DI

This commit is contained in:
Philipp Holzer 2022-10-20 22:59:12 +02:00
commit eecc456e0c
Signed by: nupplaPhil
GPG key ID: 24A7501396EB5432
78 changed files with 455 additions and 530 deletions

View file

@ -25,7 +25,6 @@ use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Module\BaseSettings;
use Friendica\Module\Response;
@ -53,11 +52,11 @@ class Trusted extends BaseSettings
$this->pConfig = $pConfig;
$this->trustedBrowserRepo = $trustedBrowserRepo;
if (!Session::getLocalUser()) {
if (!DI::userSession()->getLocalUserId()) {
return;
}
$verified = $this->pConfig->get(Session::getLocalUser(), '2fa', 'verified');
$verified = $this->pConfig->get(DI::userSession()->getLocalUserId(), '2fa', 'verified');
if (!$verified) {
$this->baseUrl->redirect('settings/2fa');
@ -71,7 +70,7 @@ class Trusted extends BaseSettings
protected function post(array $request = [])
{
if (!Session::getLocalUser()) {
if (!DI::userSession()->getLocalUserId()) {
return;
}
@ -80,7 +79,7 @@ class Trusted extends BaseSettings
switch ($_POST['action']) {
case 'remove_all':
$this->trustedBrowserRepo->removeAllForUser(Session::getLocalUser());
$this->trustedBrowserRepo->removeAllForUser(DI::userSession()->getLocalUserId());
DI::sysmsg()->addInfo($this->t('Trusted browsers successfully removed.'));
$this->baseUrl->redirect('settings/2fa/trusted?t=' . self::getFormSecurityToken('settings_2fa_password'));
break;
@ -90,7 +89,7 @@ class Trusted extends BaseSettings
if (!empty($_POST['remove_id'])) {
self::checkFormSecurityTokenRedirectOnError('settings/2fa/trusted', 'settings_2fa_trusted');
if ($this->trustedBrowserRepo->removeForUser(Session::getLocalUser(), $_POST['remove_id'])) {
if ($this->trustedBrowserRepo->removeForUser(DI::userSession()->getLocalUserId(), $_POST['remove_id'])) {
DI::sysmsg()->addInfo($this->t('Trusted browser successfully removed.'));
}
@ -103,7 +102,7 @@ class Trusted extends BaseSettings
{
parent::content();
$trustedBrowsers = $this->trustedBrowserRepo->selectAllByUid(Session::getLocalUser());
$trustedBrowsers = $this->trustedBrowserRepo->selectAllByUid(DI::userSession()->getLocalUserId());
$parser = Parser::create();