mirror of
https://github.com/friendica/friendica
synced 2025-04-26 18:30:11 +00:00
UserSession class [5] - Refactor src/Module/ files with DI
This commit is contained in:
parent
a729f3255d
commit
eecc456e0c
78 changed files with 455 additions and 530 deletions
|
@ -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\Response;
|
||||
use Friendica\Security\TwoFactor\Model\AppSpecificPassword;
|
||||
|
@ -52,11 +51,11 @@ class AppSpecific extends BaseSettings
|
|||
|
||||
$this->pConfig = $pConfig;
|
||||
|
||||
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');
|
||||
|
@ -70,7 +69,7 @@ class AppSpecific extends BaseSettings
|
|||
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -83,17 +82,17 @@ class AppSpecific extends BaseSettings
|
|||
if (empty($description)) {
|
||||
DI::sysmsg()->addNotice($this->t('App-specific password generation failed: The description is empty.'));
|
||||
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
||||
} elseif (AppSpecificPassword::checkDuplicateForUser(Session::getLocalUser(), $description)) {
|
||||
} elseif (AppSpecificPassword::checkDuplicateForUser(DI::userSession()->getLocalUserId(), $description)) {
|
||||
DI::sysmsg()->addNotice($this->t('App-specific password generation failed: This description already exists.'));
|
||||
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
||||
} else {
|
||||
$this->appSpecificPassword = AppSpecificPassword::generateForUser(Session::getLocalUser(), $_POST['description'] ?? '');
|
||||
$this->appSpecificPassword = AppSpecificPassword::generateForUser(DI::userSession()->getLocalUserId(), $_POST['description'] ?? '');
|
||||
DI::sysmsg()->addInfo($this->t('New app-specific password generated.'));
|
||||
}
|
||||
|
||||
break;
|
||||
case 'revoke_all' :
|
||||
AppSpecificPassword::deleteAllForUser(Session::getLocalUser());
|
||||
AppSpecificPassword::deleteAllForUser(DI::userSession()->getLocalUserId());
|
||||
DI::sysmsg()->addInfo($this->t('App-specific passwords successfully revoked.'));
|
||||
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
||||
break;
|
||||
|
@ -103,7 +102,7 @@ class AppSpecific extends BaseSettings
|
|||
if (!empty($_POST['revoke_id'])) {
|
||||
self::checkFormSecurityTokenRedirectOnError('settings/2fa/app_specific', 'settings_2fa_app_specific');
|
||||
|
||||
if (AppSpecificPassword::deleteForUser(Session::getLocalUser(), $_POST['revoke_id'])) {
|
||||
if (AppSpecificPassword::deleteForUser(DI::userSession()->getLocalUserId(), $_POST['revoke_id'])) {
|
||||
DI::sysmsg()->addInfo($this->t('App-specific password successfully revoked.'));
|
||||
}
|
||||
|
||||
|
@ -113,13 +112,13 @@ class AppSpecific extends BaseSettings
|
|||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return Login::form('settings/2fa/app_specific');
|
||||
}
|
||||
|
||||
parent::content();
|
||||
|
||||
$appSpecificPasswords = AppSpecificPassword::getListForUser(Session::getLocalUser());
|
||||
$appSpecificPasswords = AppSpecificPassword::getListForUser(DI::userSession()->getLocalUserId());
|
||||
|
||||
return Renderer::replaceMacros(Renderer::getMarkupTemplate('settings/twofactor/app_specific.tpl'), [
|
||||
'$form_security_token' => self::getFormSecurityToken('settings_2fa_app_specific'),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue