Skip to content

Commit

Permalink
fix: corrected possible type error, closes #2930
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Apr 30, 2024
1 parent be50862 commit f6365c5
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions phpmyfaq/ucp.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,21 @@
$gravatarImg = '';
}

$tfa = new TwoFactor($faqConfig);
$secret = $tfa->getSecret(CurrentUser::getFromSession($faqConfig));
if ('' === $secret) {
try {
$secret = $tfa->generateSecret();
} catch (TwoFactorAuthException $e) {
$faqConfig->getLogger()->error('Cannot generate 2FA secret: ' . $e->getMessage());
$qrCode = '';
try {
$tfa = new TwoFactor($faqConfig);
$secret = $tfa->getSecret(CurrentUser::getFromSession($faqConfig));
if ('' === $secret) {
try {
$secret = $tfa->generateSecret();
} catch (TwoFactorAuthException $e) {
$faqConfig->getLogger()->error('Cannot generate 2FA secret: ' . $e->getMessage());
}
$tfa->saveSecret($secret);
}
$tfa->saveSecret($secret);
$qrCode = $tfa->getQrCode($secret);
} catch (TwoFactorAuthException $e) {
// handle exception
}

$template->parse(
Expand All @@ -87,7 +93,7 @@
'msgTwofactorConfig' => Translation::get('msgTwofactorConfig'),
'msgTwofactorConfigModelTitle' => Translation::get('msgTwofactorConfigModelTitle'),
'twofactor_secret' => $secret,
'qr_code_secret' => $tfa->getQrCode($secret),
'qr_code_secret' => $qrCode,
'qr_code_secret_alt' => Translation::get('qr_code_secret_alt'),
'msgTwofactorNewSecret' => Translation::get('msgTwofactorNewSecret'),
]
Expand Down

0 comments on commit f6365c5

Please sign in to comment.