X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FSettings%2FTwoFactor%2FIndex.php;h=ab3400801eb86bf5fae13ef3e698d0ace8df7b77;hb=d6efc901946c91cf26a4436c4b58b1636e4bc9c9;hp=79b92f159291c2e94d3d434aaf5a33009fa460c2;hpb=64b10205bcf45bade54c7da00a8e485121f7458e;p=friendica.git diff --git a/src/Module/Settings/TwoFactor/Index.php b/src/Module/Settings/TwoFactor/Index.php index 79b92f1592..ab3400801e 100644 --- a/src/Module/Settings/TwoFactor/Index.php +++ b/src/Module/Settings/TwoFactor/Index.php @@ -1,23 +1,20 @@ get(local_user(), '2fa', 'secret'); + $verified = DI::pConfig()->get(local_user(), '2fa', 'verified'); - switch (defaults($_POST, 'action', '')) { + switch ($_POST['action'] ?? '') { case 'enable': if (!$has_secret && !$verified) { $Google2FA = new Google2FA(); - PConfig::set(local_user(), '2fa', 'secret', $Google2FA->generateSecretKey(32)); + DI::pConfig()->set(local_user(), '2fa', 'secret', $Google2FA->generateSecretKey(32)); - self::getApp()->internalRedirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password')); + DI::baseUrl()->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password')); } break; case 'disable': if ($has_secret) { RecoveryCode::deleteForUser(local_user()); - PConfig::delete(local_user(), '2fa', 'secret'); - PConfig::delete(local_user(), '2fa', 'verified'); + DI::pConfig()->delete(local_user(), '2fa', 'secret'); + DI::pConfig()->delete(local_user(), '2fa', 'verified'); Session::remove('2fa'); - notice(L10n::t('Two-factor authentication successfully disabled.')); - self::getApp()->internalRedirect('settings/2fa'); + notice(DI::l10n()->t('Two-factor authentication successfully disabled.')); + DI::baseUrl()->redirect('settings/2fa'); } break; case 'recovery': if ($has_secret) { - self::getApp()->internalRedirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password')); + DI::baseUrl()->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password')); } break; case 'app_specific': if ($has_secret) { - self::getApp()->internalRedirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password')); + DI::baseUrl()->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password')); } break; case 'configure': if (!$verified) { - self::getApp()->internalRedirect('settings/2fa/verify?t=' . self::getFormSecurityToken('settings_2fa_password')); + DI::baseUrl()->redirect('settings/2fa/verify?t=' . self::getFormSecurityToken('settings_2fa_password')); } break; } } catch (\Exception $e) { - notice(L10n::t('Wrong Password')); + notice(DI::l10n()->t('Wrong Password')); } } - public static function content() + public static function content(array $parameters = []) { if (!local_user()) { return Login::form('settings/2fa'); } - parent::content(); + parent::content($parameters); - $has_secret = (bool) PConfig::get(local_user(), '2fa', 'secret'); - $verified = PConfig::get(local_user(), '2fa', 'verified'); + $has_secret = (bool) DI::pConfig()->get(local_user(), '2fa', 'secret'); + $verified = DI::pConfig()->get(local_user(), '2fa', 'verified'); return Renderer::replaceMacros(Renderer::getMarkupTemplate('settings/twofactor/index.tpl'), [ '$form_security_token' => self::getFormSecurityToken('settings_2fa'), - '$title' => L10n::t('Two-factor authentication'), - '$help_label' => L10n::t('Help'), - '$status_title' => L10n::t('Status'), - '$message' => L10n::t('

Use an application on a mobile device to get two-factor authentication codes when prompted on login.

'), + '$title' => DI::l10n()->t('Two-factor authentication'), + '$help_label' => DI::l10n()->t('Help'), + '$status_title' => DI::l10n()->t('Status'), + '$message' => DI::l10n()->t('

Use an application on a mobile device to get two-factor authentication codes when prompted on login.

'), '$has_secret' => $has_secret, '$verified' => $verified, - '$auth_app_label' => L10n::t('Authenticator app'), - '$app_status' => $has_secret ? $verified ? L10n::t('Configured') : L10n::t('Not Configured') : L10n::t('Disabled'), - '$not_configured_message' => L10n::t('

You haven\'t finished configuring your authenticator app.

'), - '$configured_message' => L10n::t('

Your authenticator app is correctly configured.

'), + '$auth_app_label' => DI::l10n()->t('Authenticator app'), + '$app_status' => $has_secret ? $verified ? DI::l10n()->t('Configured') : DI::l10n()->t('Not Configured') : DI::l10n()->t('Disabled'), + '$not_configured_message' => DI::l10n()->t('

You haven\'t finished configuring your authenticator app.

'), + '$configured_message' => DI::l10n()->t('

Your authenticator app is correctly configured.

'), - '$recovery_codes_title' => L10n::t('Recovery codes'), - '$recovery_codes_remaining' => L10n::t('Remaining valid codes'), + '$recovery_codes_title' => DI::l10n()->t('Recovery codes'), + '$recovery_codes_remaining' => DI::l10n()->t('Remaining valid codes'), '$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.

'), + '$recovery_codes_message' => DI::l10n()->t('

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

'), - '$app_specific_passwords_title' => L10n::t('App-specific passwords'), - '$app_specific_passwords_remaining' => L10n::t('Generated app-specific passwords'), + '$app_specific_passwords_title' => DI::l10n()->t('App-specific passwords'), + '$app_specific_passwords_remaining' => DI::l10n()->t('Generated app-specific passwords'), '$app_specific_passwords_count' => AppSpecificPassword::countForUser(local_user()), - '$app_specific_passwords_message' => L10n::t('

These randomly generated passwords allow you to authenticate on apps not supporting two-factor authentication.

'), - - '$action_title' => L10n::t('Actions'), - '$password' => ['password', L10n::t('Current password:'), '', L10n::t('You need to provide your current password to change two-factor authentication settings.'), 'required', 'autofocus'], - '$enable_label' => L10n::t('Enable two-factor authentication'), - '$disable_label' => L10n::t('Disable two-factor authentication'), - '$recovery_codes_label' => L10n::t('Show recovery codes'), - '$app_specific_passwords_label' => L10n::t('Manage app-specific passwords'), - '$configure_label' => L10n::t('Finish app configuration'), + '$app_specific_passwords_message' => DI::l10n()->t('

These randomly generated passwords allow you to authenticate on apps not supporting two-factor authentication.

'), + + '$action_title' => DI::l10n()->t('Actions'), + '$password' => ['password', DI::l10n()->t('Current password:'), '', DI::l10n()->t('You need to provide your current password to change two-factor authentication settings.'), 'required', 'autofocus'], + '$enable_label' => DI::l10n()->t('Enable two-factor authentication'), + '$disable_label' => DI::l10n()->t('Disable two-factor authentication'), + '$recovery_codes_label' => DI::l10n()->t('Show recovery codes'), + '$app_specific_passwords_label' => DI::l10n()->t('Manage app-specific passwords'), + '$configure_label' => DI::l10n()->t('Finish app configuration'), ]); } }