From 9308656ec8e70e334fde862d6d81581ebed869d8 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Sun, 17 Mar 2024 12:16:01 -0500 Subject: [PATCH] Switch to setting the version explicitly to 0. Doing this forces the `GD::Barcode::QRcode` package to auto detect the version, ans works on all platforms to generate a working QR code. However, on some platforms (well really all of them except the packages in the Ubuntu repositories) this emits warnings. To fix that, the warnings are simply disabled when the image is generated. --- lib/WeBWorK/ContentGenerator/TwoFactorAuthentication.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/WeBWorK/ContentGenerator/TwoFactorAuthentication.pm b/lib/WeBWorK/ContentGenerator/TwoFactorAuthentication.pm index b0156f9984..08e22e8a01 100644 --- a/lib/WeBWorK/ContentGenerator/TwoFactorAuthentication.pm +++ b/lib/WeBWorK/ContentGenerator/TwoFactorAuthentication.pm @@ -55,7 +55,11 @@ sub pre_header_initialize ($c) { $c->authen->session(otp_secret => $totp->secret); my $otp_link = $totp->generate_otp($c->authen->{user_id}, $ce->{courseName}); - my $img_data = GD::Barcode::QRcode->new($otp_link, { ModuleSize => 4, Version => 12 })->plot->png; + + my $img_data = do { + local $SIG{__WARN__} = sub { }; + GD::Barcode::QRcode->new($otp_link, { Ecc => 'L', ModuleSize => 4, Version => 0 })->plot->png; + }; my $user = $c->db->getUser($c->authen->{user_id});