Skip to content

Commit

Permalink
Switch to setting the version explicitly to 0.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
drgrice1 committed Mar 18, 2024
1 parent a07d02a commit d81e4f7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/WeBWorK/ContentGenerator/TwoFactorAuthentication.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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});

Expand Down

0 comments on commit d81e4f7

Please sign in to comment.