1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-09-15 18:57:05 +00:00

fixup! Add a two-step setup of OTP

Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
This commit is contained in:
Kevin Decherf 2025-07-20 19:03:54 +02:00
parent e674458f22
commit 053c76d51a
2 changed files with 13 additions and 2 deletions

View file

@ -147,7 +147,9 @@ class User extends BaseUser implements EmailTwoFactorInterface, GoogleTwoFactorI
#[ORM\Column(name: 'googleAuthenticatorSecret', type: 'string', nullable: true)] #[ORM\Column(name: 'googleAuthenticatorSecret', type: 'string', nullable: true)]
private $googleAuthenticatorSecret; private $googleAuthenticatorSecret;
#[ORM\Column(name: 'google_authenticator', type: 'boolean')] // default value is explicitly set to false here to ensure that Doctrine
// does not complain about schema mapping mismatch
#[ORM\Column(name: 'google_authenticator', type: 'boolean', options: ['default' => false])]
private $googleAuthenticator = false; private $googleAuthenticator = false;
/** /**

View file

@ -1253,6 +1253,13 @@ class ConfigControllerTest extends WallabagTestCase
$secret = $crawler->filter('div#config_otp_app_secret pre code')->innerText(); $secret = $crawler->filter('div#config_otp_app_secret pre code')->innerText();
$this->assertSame('DUMMYSECRET', $secret); $this->assertSame('DUMMYSECRET', $secret);
$em = $this->getEntityManager();
$user = $em
->getRepository(User::class)
->findOneByUsername('admin');
// At this phase, the user should not have 2FA enabled
$this->assertFalse($user->isGoogleTwoFactor());
// First test: send invalid OTP code // First test: send invalid OTP code
$form = $crawler->filter('form[name=config_otp_app_check]')->form(); $form = $crawler->filter('form[name=config_otp_app_check]')->form();
$data = [ $data = [
@ -1286,6 +1293,7 @@ class ConfigControllerTest extends WallabagTestCase
// Restore user // Restore user
$user->setGoogleAuthenticatorSecret(null); $user->setGoogleAuthenticatorSecret(null);
$user->setGoogleAuthenticator(false);
$user->setBackupCodes([]); $user->setBackupCodes([]);
$em->persist($user); $em->persist($user);
$em->flush(); $em->flush();
@ -1302,6 +1310,7 @@ class ConfigControllerTest extends WallabagTestCase
->findOneByUsername('admin'); ->findOneByUsername('admin');
$user->setGoogleAuthenticatorSecret('Google2FA'); $user->setGoogleAuthenticatorSecret('Google2FA');
$user->setGoogleAuthenticator(true);
$em->persist($user); $em->persist($user);
$em->flush(); $em->flush();
@ -1314,7 +1323,6 @@ class ConfigControllerTest extends WallabagTestCase
$this->assertStringContainsString('flashes.config.notice.otp_disabled', $client->getContainer()->get(SessionInterface::class)->getFlashBag()->get('notice')[0]); $this->assertStringContainsString('flashes.config.notice.otp_disabled', $client->getContainer()->get(SessionInterface::class)->getFlashBag()->get('notice')[0]);
// restore user
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$user = $em $user = $em
->getRepository(User::class) ->getRepository(User::class)
@ -1322,6 +1330,7 @@ class ConfigControllerTest extends WallabagTestCase
$this->assertEmpty($user->getGoogleAuthenticatorSecret()); $this->assertEmpty($user->getGoogleAuthenticatorSecret());
$this->assertEmpty($user->getBackupCodes()); $this->assertEmpty($user->getBackupCodes());
$this->assertFalse($user->isGoogleTwoFactor());
} }
public function testExportTaggingRule() public function testExportTaggingRule()