@@ -, +, @@ and script --- Koha/Auth/TwoFactorAuth.pm | 2 +- members/two_factor_auth.pl | 2 +- t/db_dependent/Koha/Auth/TwoFactorAuth.t | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) --- a/Koha/Auth/TwoFactorAuth.pm +++ a/Koha/Auth/TwoFactorAuth.pm @@ -68,7 +68,7 @@ sub new { } elsif( $secret ) { $type = 'secret'; } elsif( $patron->secret ) { - $secret32 = $patron->secret; # saved already in base32 + $secret32 = $patron->decoded_secret; # saved already in base32 } else { Koha::Exceptions::MissingParameter->throw("No secret passed or patron has no secret"); } --- a/members/two_factor_auth.pl +++ a/members/two_factor_auth.pl @@ -69,7 +69,7 @@ if ( $op eq 'register-2FA' ) { if ($verified) { # FIXME Generate a (new?) secret - $logged_in_user->secret($secret32); + $logged_in_user->encode_secret($secret32); $logged_in_user->auth_method('two-factor')->store; $op = 'registered'; if( $logged_in_user->notice_email_address ) { --- a/t/db_dependent/Koha/Auth/TwoFactorAuth.t +++ a/t/db_dependent/Koha/Auth/TwoFactorAuth.t @@ -42,10 +42,10 @@ subtest 'new' => sub { 'Croaked on wrong encoding'; # Test passing secret or secret32 (converted to base32) - $patron->secret('nv4v65dpobpxgzldojsxiii'); # this is base32 already for 'my_top_secret!' + $patron->encode_secret('nv4v65dpobpxgzldojsxiii'); # this is base32 already for 'my_top_secret!' my $auth = Koha::Auth::TwoFactorAuth->new({ patron => $patron }); - is( $auth->secret32, $patron->secret, 'Base32 secret as expected' ); - $auth->code( $patron->secret ); # trigger conversion by passing base32 to code + is( $auth->secret32, $patron->decoded_secret, 'Base32 secret as expected' ); + $auth->code( $patron->decoded_secret ); # trigger conversion by passing base32 to code is( $auth->secret, 'my_top_secret!', 'Decoded secret fine too' ); # The other way around $auth = Koha::Auth::TwoFactorAuth->new({ patron => $patron, secret => 'my_top_secret!' }); @@ -64,7 +64,7 @@ subtest 'qr_code' => sub { t::lib::Mocks::mock_preference('TwoFactorAuthentication', 1); my $patron = $builder->build_object({ class => 'Koha::Patrons' }); - $patron->secret('you2wont2guess2it'); # this is base32 btw + $patron->encode_secret('you2wont2guess2it'); # this is base32 btw $patron->auth_method('two-factor'); $patron->store; @@ -76,7 +76,7 @@ subtest 'qr_code' => sub { $auth->clear; # Changing the secret should generate different data, right? - $patron->secret('no3really3not3cracked'); # base32 + $patron->encode_secret('no3really3not3cracked'); # base32 $patron->store; $auth = Koha::Auth::TwoFactorAuth->new({ patron => $patron }); my $img_data02 = $auth->qr_code; --