adaptions

This commit is contained in:
Philipp 2022-06-26 10:13:32 +02:00
parent 2248850f78
commit b67e488236
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
3 changed files with 24 additions and 19 deletions

View file

@ -45,8 +45,8 @@ class Index extends BaseSettings
try {
User::getIdFromPasswordAuthentication(local_user(), $_POST['password'] ?? '');
$has_secret = (bool) DI::pConfig()->get(local_user(), '2fa', 'secret');
$verified = DI::pConfig()->get(local_user(), '2fa', 'verified');
$has_secret = (bool)DI::pConfig()->get(local_user(), '2fa', 'secret');
$verified = DI::pConfig()->get(local_user(), '2fa', 'verified');
switch ($_POST['action'] ?? '') {
case 'enable':
@ -55,7 +55,8 @@ class Index extends BaseSettings
DI::pConfig()->set(local_user(), '2fa', 'secret', $Google2FA->generateSecretKey(32));
DI::baseUrl()->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password'));
DI::baseUrl()
->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password'));
}
break;
case 'disable':
@ -71,29 +72,33 @@ class Index extends BaseSettings
break;
case 'recovery':
if ($has_secret) {
DI::baseUrl()->redirect('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) {
DI::baseUrl()->redirect('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 'trusted':
if ($has_secret) {
DI::baseUrl()->redirect('settings/2fa/trusted?t=' . self::getFormSecurityToken('settings_2fa_password'));
DI::baseUrl()
->redirect('settings/2fa/trusted?t=' . self::getFormSecurityToken('settings_2fa_password'));
}
break;
case 'configure':
if (!$verified) {
DI::baseUrl()->redirect('settings/2fa/verify?t=' . self::getFormSecurityToken('settings_2fa_password'));
DI::baseUrl()
->redirect('settings/2fa/verify?t=' . self::getFormSecurityToken('settings_2fa_password'));
}
break;
}
} catch (FoundException $exception) {
// Nothing to do here
} catch (\Exception $e) {
if (!($e instanceof FoundException)) {
notice(DI::l10n()->t($e->getMessage()));
}
notice(DI::l10n()->t($e->getMessage()));
}
}