Lines 42-74
if ( $TwoFactorAuthentication ne 'enabled' && $TwoFactorAuthentication ne 'enfor
Link Here
|
42 |
exit; |
42 |
exit; |
43 |
} |
43 |
} |
44 |
|
44 |
|
|
|
45 |
my $op = $cgi->param('op') // ''; |
46 |
my $patron_id = $cgi->param('borrowernumber') // ''; |
47 |
|
48 |
my $another_user = $patron_id ne $loggedinuser; |
49 |
|
45 |
my $logged_in_user = Koha::Patrons->find($loggedinuser); |
50 |
my $logged_in_user = Koha::Patrons->find($loggedinuser); |
46 |
my $op = $cgi->param('op') // ''; |
51 |
|
|
|
52 |
unless ( !$another_user || $logged_in_user->is_superlibrarian() ) { |
53 |
print $cgi->redirect("/cgi-bin/koha/errors/403.pl"); |
54 |
exit; |
55 |
} |
56 |
|
57 |
my $patron = |
58 |
$another_user |
59 |
? Koha::Patrons->find($patron_id) |
60 |
: $logged_in_user; |
61 |
|
62 |
if ( !$patron ) { |
63 |
print $cgi->redirect("/cgi-bin/koha/errors/404.pl"); |
64 |
exit; |
65 |
} |
47 |
|
66 |
|
48 |
if ( !C4::Context->config('encryption_key') ) { |
67 |
if ( !C4::Context->config('encryption_key') ) { |
49 |
$template->param( missing_key => 1 ); |
68 |
$template->param( missing_key => 1 ); |
50 |
} else { |
69 |
} else { |
51 |
|
70 |
|
52 |
my $csrf_pars = { |
|
|
53 |
session_id => scalar $cgi->cookie('CGISESSID'), |
54 |
token => scalar $cgi->param('csrf_token'), |
55 |
}; |
56 |
|
57 |
if ( $op eq 'cud-disable-2FA' ) { |
71 |
if ( $op eq 'cud-disable-2FA' ) { |
58 |
my $auth = Koha::Auth::TwoFactorAuth->new( { patron => $logged_in_user } ); |
72 |
|
59 |
$logged_in_user->secret(undef); |
73 |
$patron->reset_2fa(); |
60 |
$logged_in_user->auth_method('password')->store; |
74 |
|
61 |
if ( $logged_in_user->notice_email_address ) { |
75 |
if ( $patron->notice_email_address ) { |
62 |
$logged_in_user->queue_notice( |
76 |
$patron->queue_notice( |
63 |
{ |
77 |
{ |
64 |
letter_params => { |
78 |
letter_params => { |
65 |
module => 'members', |
79 |
module => 'members', |
66 |
letter_code => '2FA_DISABLE', |
80 |
letter_code => '2FA_DISABLE', |
67 |
branchcode => $logged_in_user->branchcode, |
81 |
branchcode => $patron->branchcode, |
68 |
lang => $logged_in_user->lang, |
82 |
lang => $patron->lang, |
69 |
tables => { |
83 |
tables => { |
70 |
branches => $logged_in_user->branchcode, |
84 |
branches => $patron->branchcode, |
71 |
borrowers => $logged_in_user->id |
85 |
borrowers => $patron->id |
72 |
}, |
86 |
}, |
73 |
}, |
87 |
}, |
74 |
message_transports => ['email'], |
88 |
message_transports => ['email'], |
Lines 79-86
if ( !C4::Context->config('encryption_key') ) {
Link Here
|
79 |
} |
93 |
} |
80 |
|
94 |
|
81 |
$template->param( |
95 |
$template->param( |
82 |
patron => $logged_in_user, |
96 |
another_user => $another_user, |
83 |
op => $op, |
97 |
op => $op, |
|
|
98 |
patron => $patron, |
84 |
); |
99 |
); |
85 |
|
100 |
|
86 |
output_html_with_http_headers $cgi, $cookie, $template->output; |
101 |
output_html_with_http_headers $cgi, $cookie, $template->output; |
87 |
- |
|
|