From a149d6ec4448ee6c38f2b6ee4c2e907cdf20d5b3 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 22 Jul 2019 07:41:01 -0400 Subject: [PATCH] Move recovery code model to sub-folder --- .../RecoveryCode.php} | 4 ++-- src/Module/Settings/TwoFactor/Index.php | 6 +++--- src/Module/Settings/TwoFactor/Recovery.php | 10 +++++----- src/Module/TwoFactor/Recovery.php | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) rename src/Model/{TwoFactorRecoveryCode.php => TwoFactor/RecoveryCode.php} (97%) diff --git a/src/Model/TwoFactorRecoveryCode.php b/src/Model/TwoFactor/RecoveryCode.php similarity index 97% rename from src/Model/TwoFactorRecoveryCode.php rename to src/Model/TwoFactor/RecoveryCode.php index 74dead32d9..676b538378 100644 --- a/src/Model/TwoFactorRecoveryCode.php +++ b/src/Model/TwoFactor/RecoveryCode.php @@ -1,6 +1,6 @@ L10n::t('Recovery codes'), '$recovery_codes_remaining' => L10n::t('Remaining valid codes'), - '$recovery_codes_count' => TwoFactorRecoveryCode::countValidForUser(local_user()), + '$recovery_codes_count' => RecoveryCode::countValidForUser(local_user()), '$recovery_codes_message' => L10n::t('

These one-use codes can replace an authenticator app code in case you have lost access to it.

'), '$action_title' => L10n::t('Actions'), diff --git a/src/Module/Settings/TwoFactor/Recovery.php b/src/Module/Settings/TwoFactor/Recovery.php index a2d08cda86..6937fa503f 100644 --- a/src/Module/Settings/TwoFactor/Recovery.php +++ b/src/Module/Settings/TwoFactor/Recovery.php @@ -7,7 +7,7 @@ namespace Friendica\Module\Settings\TwoFactor; use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Core\Renderer; -use Friendica\Model\TwoFactorRecoveryCode; +use Friendica\Model\TwoFactor\RecoveryCode; use Friendica\Module\BaseSettingsModule; use Friendica\Module\Login; @@ -46,7 +46,7 @@ class Recovery extends BaseSettingsModule self::checkFormSecurityTokenRedirectOnError('settings/2fa/recovery', 'settings_2fa_recovery'); if ($_POST['action'] == 'regenerate') { - TwoFactorRecoveryCode::regenerateForUser(local_user()); + RecoveryCode::regenerateForUser(local_user()); notice(L10n::t('New recovery codes successfully generated.')); self::getApp()->internalRedirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password')); } @@ -61,11 +61,11 @@ class Recovery extends BaseSettingsModule parent::content(); - if (!TwoFactorRecoveryCode::countValidForUser(local_user())) { - TwoFactorRecoveryCode::generateForUser(local_user()); + if (!RecoveryCode::countValidForUser(local_user())) { + RecoveryCode::generateForUser(local_user()); } - $recoveryCodes = TwoFactorRecoveryCode::getListForUser(local_user()); + $recoveryCodes = RecoveryCode::getListForUser(local_user()); $verified = PConfig::get(local_user(), '2fa', 'verified'); diff --git a/src/Module/TwoFactor/Recovery.php b/src/Module/TwoFactor/Recovery.php index 4952d220b7..60f443c35f 100644 --- a/src/Module/TwoFactor/Recovery.php +++ b/src/Module/TwoFactor/Recovery.php @@ -6,7 +6,7 @@ use Friendica\BaseModule; use Friendica\Core\L10n; use Friendica\Core\Renderer; use Friendica\Core\Session; -use Friendica\Model\TwoFactorRecoveryCode; +use Friendica\Model\TwoFactor\RecoveryCode; /** * // Page 1a: Recovery code verification @@ -35,10 +35,10 @@ class Recovery extends BaseModule $recovery_code = defaults($_POST, 'recovery_code', ''); - if (TwoFactorRecoveryCode::existsForUser(local_user(), $recovery_code)) { - TwoFactorRecoveryCode::markUsedForUser(local_user(), $recovery_code); + if (RecoveryCode::existsForUser(local_user(), $recovery_code)) { + RecoveryCode::markUsedForUser(local_user(), $recovery_code); Session::set('2fa', true); - notice(L10n::t('Remaining recovery codes: %d', TwoFactorRecoveryCode::countValidForUser(local_user()))); + notice(L10n::t('Remaining recovery codes: %d', RecoveryCode::countValidForUser(local_user()))); // Resume normal login workflow Session::setAuthenticatedForUser($a, $a->user, true, true); -- 2.39.5