Browse Source

Move recovery code model to sub-folder

pull/7419/head
Hypolite Petovan 2 years ago
parent
commit
a149d6ec44
4 changed files with 14 additions and 14 deletions
  1. +2
    -2
      src/Model/TwoFactor/RecoveryCode.php
  2. +3
    -3
      src/Module/Settings/TwoFactor/Index.php
  3. +5
    -5
      src/Module/Settings/TwoFactor/Recovery.php
  4. +4
    -4
      src/Module/TwoFactor/Recovery.php

src/Model/TwoFactorRecoveryCode.php → src/Model/TwoFactor/RecoveryCode.php View File


+ 3
- 3
src/Module/Settings/TwoFactor/Index.php View File

@ -8,7 +8,7 @@ use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Model\TwoFactorRecoveryCode;
use Friendica\Model\TwoFactor\RecoveryCode;
use Friendica\Model\User;
use Friendica\Module\BaseSettingsModule;
use Friendica\Module\Login;
@ -42,7 +42,7 @@ class Index extends BaseSettingsModule
break;
case 'disable':
if ($has_secret) {
TwoFactorRecoveryCode::deleteForUser(local_user());
RecoveryCode::deleteForUser(local_user());
PConfig::delete(local_user(), '2fa', 'secret');
PConfig::delete(local_user(), '2fa', 'verified');
Session::remove('2fa');
@ -94,7 +94,7 @@ class Index extends BaseSettingsModule
'$recovery_codes_title' => 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('<p>These one-use codes can replace an authenticator app code in case you have lost access to it.</p>'),
'$action_title' => L10n::t('Actions'),


+ 5
- 5
src/Module/Settings/TwoFactor/Recovery.php View File

@ -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');


+ 4
- 4
src/Module/TwoFactor/Recovery.php View File

@ -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);


Loading…
Cancel
Save