From d827ee310a7a9ff97cf46b1bca08b1afb546df62 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 13 Sep 2021 23:13:44 +0200 Subject: [PATCH] Bug 28786: Correctly inherit from Auth::GoogleAuth Signed-off-by: Marcel de Rooy Signed-off-by: Fridolin Somers --- C4/Auth.pm | 2 +- Koha/Auth/TwoFactorAuth.pm | 6 +++--- members/two_factor_auth.pl | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 51a8b5db9e..c1c27e0eb9 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -909,7 +909,7 @@ sub checkauth { && ( my $otp_token = $query->param('otp_token') ) ) { my $patron = Koha::Patrons->find( { userid => $userid } ); - my $auth = Koha::Auth::TwoFactorAuth::get_auth( { patron => $patron } ); + my $auth = Koha::Auth::TwoFactorAuth->new( { patron => $patron } ); my $verified = $auth->verify($otp_token); $auth->clear; if ( $verified ) { diff --git a/Koha/Auth/TwoFactorAuth.pm b/Koha/Auth/TwoFactorAuth.pm index c08736f506..f66379200d 100644 --- a/Koha/Auth/TwoFactorAuth.pm +++ b/Koha/Auth/TwoFactorAuth.pm @@ -38,8 +38,8 @@ It's based on Auth::GoogleAuth =cut -sub get_auth { - my ($params) = @_; +sub new { + my ($class, $params) = @_; my $patron = $params->{patron}; my $secret = $params->{secret}; my $secret32 = $params->{secret32}; @@ -52,7 +52,7 @@ sub get_auth { my $key_id = sprintf "%s_%s", $issuer, ( $patron->email || $patron->userid ); - return Auth::GoogleAuth->new( + return $class->SUPER::new( { ( $secret ? ( secret => $secret ) : () ), ( $secret32 ? ( secret32 => $secret32 ) : () ), diff --git a/members/two_factor_auth.pl b/members/two_factor_auth.pl index ce5143ea7d..2a5a996c56 100644 --- a/members/two_factor_auth.pl +++ b/members/two_factor_auth.pl @@ -48,7 +48,7 @@ my $op = $cgi->param('op') // ''; if ( $op eq 'register-2FA' ) { my $pin_code = $cgi->param('pin_code'); my $secret32 = $cgi->param('secret32'); - my $auth = Koha::Auth::TwoFactorAuth::get_auth( + my $auth = Koha::Auth::TwoFactorAuth->new( { patron => $logged_in_user, secret32 => $secret32 } ); my $verified = $auth->verify( @@ -75,7 +75,7 @@ if ( $op eq 'register-2FA' ) { if ( $op eq 'enable-2FA' ) { my $secret = Koha::AuthUtils::generate_salt( 'weak', 16 ); - my $auth = Koha::Auth::TwoFactorAuth::get_auth( + my $auth = Koha::Auth::TwoFactorAuth->new( { patron => $logged_in_user, secret => $secret } ); my $secret32 = $auth->generate_secret32; -- 2.39.5