From a2a747d785356121e5571ae8d4ae5a9367fb75dd Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 8 Jun 2023 14:53:45 +0100 Subject: [PATCH] Bug 33904: (follow-up) Perltidy With the recent introduction of a community perltidyrc, I felt it sensible to give the module a tidy with this patch. --- Koha/Auth/TwoFactorAuth.pm | 41 ++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/Koha/Auth/TwoFactorAuth.pm b/Koha/Auth/TwoFactorAuth.pm index 6937ab9060..15a16c42bc 100644 --- a/Koha/Auth/TwoFactorAuth.pm +++ b/Koha/Auth/TwoFactorAuth.pm @@ -53,10 +53,10 @@ It's based on Auth::GoogleAuth =cut sub new { - my ($class, $params) = @_; + my ( $class, $params ) = @_; my $patron = $params->{patron}; my $secret32 = $params->{secret32}; - my $secret = $params->{secret}; + my $secret = $params->{secret}; # FIXME Raise an exception if the syspref is disabled @@ -64,26 +64,28 @@ sub new { unless $patron && ref($patron) eq 'Koha::Patron'; my $type = 'secret32'; - if( $secret32 ) { + if ($secret32) { Koha::Exceptions::BadParameter->throw("Secret32 should be base32") if $secret32 =~ /[^a-z2-7]/; - } elsif( $secret ) { + } elsif ($secret) { $type = 'secret'; - } elsif( $patron->secret ) { - $secret32 = $patron->decoded_secret; # saved already in base32 + } elsif ( $patron->secret ) { + $secret32 = $patron->decoded_secret; # saved already in base32 } else { Koha::Exceptions::MissingParameter->throw("No secret passed or patron has no secret"); } - my $issuer = Encode::encode_utf8($patron->library->branchname); + my $issuer = Encode::encode_utf8( $patron->library->branchname ); my $key_id = sprintf "%s_%s", - $issuer, ( $patron->email || $patron->userid ); - - return $class->SUPER::new({ - $type => $secret32 || $secret, - issuer => $issuer, - key_id => $key_id, - }); + $issuer, ( $patron->email || $patron->userid ); + + return $class->SUPER::new( + { + $type => $secret32 || $secret, + issuer => $issuer, + key_id => $key_id, + } + ); } =head3 qr_code @@ -97,13 +99,14 @@ sub new { =cut sub qr_code { - my ( $self ) = @_; + my ($self) = @_; + + my $otpauth = $self->SUPER::qr_code( undef, undef, undef, 1 ); - my $otpauth = $self->SUPER::qr_code( undef, undef, undef, 1); - # no need to pass secret, key and issuer again + # no need to pass secret, key and issuer again my $qrcode = GD::Barcode->new( 'QRcode', $otpauth, { Ecc => 'M', Version => 10, ModuleSize => 4 } ); - my $data = $qrcode->plot->png; - return "data:image/png;base64,". encode_base64( $data, q{} ); # does not contain newlines + my $data = $qrcode->plot->png; + return "data:image/png;base64," . encode_base64( $data, q{} ); # does not contain newlines } 1; -- 2.41.0