|
Lines 68-78
if ( $op eq 'register-2FA' ) {
Link Here
|
| 68 |
); |
68 |
); |
| 69 |
|
69 |
|
| 70 |
if ($verified) { |
70 |
if ($verified) { |
| 71 |
$logged_in_user->secret($secret32); |
|
|
| 72 |
$op = 'registered'; |
| 73 |
|
| 74 |
# FIXME Generate a (new?) secret |
71 |
# FIXME Generate a (new?) secret |
|
|
72 |
$logged_in_user->secret($secret32); |
| 75 |
$logged_in_user->auth_method('two-factor')->store; |
73 |
$logged_in_user->auth_method('two-factor')->store; |
|
|
74 |
$op = 'registered'; |
| 76 |
} |
75 |
} |
| 77 |
else { |
76 |
else { |
| 78 |
$template->param( invalid_pin => 1, ); |
77 |
$template->param( invalid_pin => 1, ); |
|
Lines 81-87
if ( $op eq 'register-2FA' ) {
Link Here
|
| 81 |
} |
80 |
} |
| 82 |
|
81 |
|
| 83 |
if ( $op eq 'enable-2FA' ) { |
82 |
if ( $op eq 'enable-2FA' ) { |
| 84 |
|
|
|
| 85 |
my $secret = Koha::AuthUtils::generate_salt( 'weak', 16 ); |
83 |
my $secret = Koha::AuthUtils::generate_salt( 'weak', 16 ); |
| 86 |
my $auth = Koha::Auth::TwoFactorAuth->new( |
84 |
my $auth = Koha::Auth::TwoFactorAuth->new( |
| 87 |
{ patron => $logged_in_user, secret => $secret } ); |
85 |
{ patron => $logged_in_user, secret => $secret } ); |
|
Lines 99-104
if ( $op eq 'enable-2FA' ) {
Link Here
|
| 99 |
elsif ( $op eq 'disable-2FA' ) { |
97 |
elsif ( $op eq 'disable-2FA' ) { |
| 100 |
output_and_exit( $cgi, $cookie, $template, 'wrong_csrf_token' ) |
98 |
output_and_exit( $cgi, $cookie, $template, 'wrong_csrf_token' ) |
| 101 |
unless Koha::Token->new->check_csrf($csrf_pars); |
99 |
unless Koha::Token->new->check_csrf($csrf_pars); |
|
|
100 |
$logged_in_user->secret(undef); |
| 102 |
$logged_in_user->auth_method('password')->store; |
101 |
$logged_in_user->auth_method('password')->store; |
| 103 |
} |
102 |
} |
| 104 |
|
103 |
|
| 105 |
- |
|
|