X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FSettings%2FTwoFactor%2FAppSpecific.php;h=94dfc6d4121df6ada787f62fc069c996c3021c15;hb=561aba18e3a230c0912ad9483c6df43cc40e09d6;hp=8c11af0295fbcf0270fa2ed9dbd0159970e49e35;hpb=9a4128a5c8af7c9791d9196266cbec43c11adb16;p=friendica.git diff --git a/src/Module/Settings/TwoFactor/AppSpecific.php b/src/Module/Settings/TwoFactor/AppSpecific.php index 8c11af0295..94dfc6d412 100644 --- a/src/Module/Settings/TwoFactor/AppSpecific.php +++ b/src/Module/Settings/TwoFactor/AppSpecific.php @@ -1,6 +1,6 @@ pConfig = $pConfig; + if (!local_user()) { return; } - $verified = DI::pConfig()->get(local_user(), '2fa', 'verified'); + $verified = $this->pConfig->get(local_user(), '2fa', 'verified'); if (!$verified) { - DI::baseUrl()->redirect('settings/2fa'); + $this->baseUrl->redirect('settings/2fa'); } if (!self::checkFormSecurityToken('settings_2fa_password', 't')) { - notice(DI::l10n()->t('Please enter your password to access this page.')); - DI::baseUrl()->redirect('settings/2fa'); + notice($this->t('Please enter your password to access this page.')); + $this->baseUrl->redirect('settings/2fa'); } } - public static function post(array $parameters = []) + protected function post(array $request = [], array $post = []) { if (!local_user()) { return; @@ -67,21 +79,21 @@ class AppSpecific extends BaseSettings case 'generate': $description = $_POST['description'] ?? ''; if (empty($description)) { - notice(DI::l10n()->t('App-specific password generation failed: The description is empty.')); - DI::baseUrl()->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password')); + notice($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(local_user(), $description)) { - notice(DI::l10n()->t('App-specific password generation failed: This description already exists.')); - DI::baseUrl()->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password')); + notice($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 { - self::$appSpecificPassword = AppSpecificPassword::generateForUser(local_user(), $_POST['description'] ?? ''); - info(DI::l10n()->t('New app-specific password generated.')); + $this->appSpecificPassword = AppSpecificPassword::generateForUser(local_user(), $_POST['description'] ?? ''); + info($this->t('New app-specific password generated.')); } break; case 'revoke_all' : AppSpecificPassword::deleteAllForUser(local_user()); - info(DI::l10n()->t('App-specific passwords successfully revoked.')); - DI::baseUrl()->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password')); + info($this->t('App-specific passwords successfully revoked.')); + $this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password')); break; } } @@ -90,20 +102,20 @@ class AppSpecific extends BaseSettings self::checkFormSecurityTokenRedirectOnError('settings/2fa/app_specific', 'settings_2fa_app_specific'); if (AppSpecificPassword::deleteForUser(local_user(), $_POST['revoke_id'])) { - info(DI::l10n()->t('App-specific password successfully revoked.')); + info($this->t('App-specific password successfully revoked.')); } - DI::baseUrl()->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password')); + $this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password')); } } - public static function content(array $parameters = []) + protected function content(array $request = []): string { if (!local_user()) { return Login::form('settings/2fa/app_specific'); } - parent::content($parameters); + parent::content(); $appSpecificPasswords = AppSpecificPassword::getListForUser(local_user()); @@ -111,22 +123,22 @@ class AppSpecific extends BaseSettings '$form_security_token' => self::getFormSecurityToken('settings_2fa_app_specific'), '$password_security_token' => self::getFormSecurityToken('settings_2fa_password'), - '$title' => DI::l10n()->t('Two-factor app-specific passwords'), - '$help_label' => DI::l10n()->t('Help'), - '$message' => DI::l10n()->t('

App-specific passwords are randomly generated passwords used instead your regular password to authenticate your account on third-party applications that don\'t support two-factor authentication.

'), - '$generated_message' => DI::l10n()->t('Make sure to copy your new app-specific password now. You won’t be able to see it again!'), - '$generated_app_specific_password' => self::$appSpecificPassword, + '$title' => $this->t('Two-factor app-specific passwords'), + '$help_label' => $this->t('Help'), + '$message' => $this->t('

App-specific passwords are randomly generated passwords used instead your regular password to authenticate your account on third-party applications that don\'t support two-factor authentication.

'), + '$generated_message' => $this->t('Make sure to copy your new app-specific password now. You won’t be able to see it again!'), + '$generated_app_specific_password' => $this->appSpecificPassword, - '$description_label' => DI::l10n()->t('Description'), - '$last_used_label' => DI::l10n()->t('Last Used'), - '$revoke_label' => DI::l10n()->t('Revoke'), - '$revoke_all_label' => DI::l10n()->t('Revoke All'), + '$description_label' => $this->t('Description'), + '$last_used_label' => $this->t('Last Used'), + '$revoke_label' => $this->t('Revoke'), + '$revoke_all_label' => $this->t('Revoke All'), '$app_specific_passwords' => $appSpecificPasswords, - '$generate_message' => DI::l10n()->t('When you generate a new app-specific password, you must use it right away, it will be shown to you once after you generate it.'), - '$generate_title' => DI::l10n()->t('Generate new app-specific password'), - '$description_placeholder_label' => DI::l10n()->t('Friendiqa on my Fairphone 2...'), - '$generate_label' => DI::l10n()->t('Generate'), + '$generate_message' => $this->t('When you generate a new app-specific password, you must use it right away, it will be shown to you once after you generate it.'), + '$generate_title' => $this->t('Generate new app-specific password'), + '$description_placeholder_label' => $this->t('Friendiqa on my Fairphone 2...'), + '$generate_label' => $this->t('Generate'), ]); } }