|
Lines 10-15
Link Here
|
| 10 |
[% WRAPPER 'header.inc' %] |
10 |
[% WRAPPER 'header.inc' %] |
| 11 |
[% INCLUDE 'patron-search-header.inc' %] |
11 |
[% INCLUDE 'patron-search-header.inc' %] |
| 12 |
[% END %] |
12 |
[% END %] |
|
|
13 |
[% PROCESS 'auth-two-factor.inc' %] |
| 13 |
|
14 |
|
| 14 |
[% WRAPPER 'sub-header.inc' %] |
15 |
[% WRAPPER 'sub-header.inc' %] |
| 15 |
<nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb"> |
16 |
<nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb"> |
|
Lines 45-87
Link Here
|
| 45 |
</p> |
46 |
</p> |
| 46 |
</div> |
47 |
</div> |
| 47 |
[% ELSE %] |
48 |
[% ELSE %] |
|
|
49 |
[% PROCESS registration_form %] |
| 48 |
|
50 |
|
| 49 |
[% IF op == 'register' %] |
51 |
<div id="registration-status"> |
| 50 |
<div class="dialog message"> |
|
|
| 51 |
<p>We recommend cloud-based mobile authenticator apps such as Authy, Duo Mobile, and LastPass. They can restore access if you lose your hardware device.</p> |
| 52 |
<p>Can't scan the code?</p> |
| 53 |
<p>To add the entry manually, provide the following details to the application on your phone.</p> |
| 54 |
<p>Account: [% issuer | html %]</p> |
| 55 |
<p>Key: [% key_id | html %]</p> |
| 56 |
<p>Time based: Yes</p> |
| 57 |
</div> |
| 58 |
|
| 59 |
[% IF invalid_pin %] |
| 60 |
<div class="dialog error">Invalid PIN code</div> |
| 61 |
[% END %] |
| 62 |
<form id="two-factor-auth" action="/cgi-bin/koha/members/two_factor_auth.pl" method="post"> |
| 63 |
<fieldset class="rows"> |
| 64 |
<input type="hidden" name="csrf_token" value="[% csrf_token | html %]" /> |
| 65 |
<input type="hidden" name="op" value="register-2FA" /> |
| 66 |
<input type="hidden" name="secret32" value="[% secret32 | html %]" /> |
| 67 |
<ol> |
| 68 |
<li> |
| 69 |
<label for="qr_code">QR code: </label> |
| 70 |
<img id="qr_code" src="[% qr_code | $raw %]" /> |
| 71 |
</li> |
| 72 |
<li> |
| 73 |
<label for="pin_code">PIN code: </label> |
| 74 |
<input type="text" id="pin_code" name="pin_code" value="" /> |
| 75 |
</li> |
| 76 |
</ol> |
| 77 |
</fieldset> |
| 78 |
<fieldset class="action"> |
| 79 |
<input type="submit" value="Register with two-factor app" /> |
| 80 |
<a class="cancel" href="/cgi-bin/koha/members/two_factor_auth.pl">Cancel</a> |
| 81 |
</fieldset> |
| 82 |
</form> |
| 83 |
[% ELSE %] |
| 84 |
[% IF patron.auth_method == "two-factor" %] |
52 |
[% IF patron.auth_method == "two-factor" %] |
|
|
53 |
<div id="registration-status-enabled"> |
| 54 |
[% ELSE %] |
| 55 |
<div id="registration-status-enabled" style="display: none;"> |
| 56 |
[% END %] |
| 85 |
<div class="two-factor-status">Status: Enabled</div> |
57 |
<div class="two-factor-status">Status: Enabled</div> |
| 86 |
|
58 |
|
| 87 |
<form id="two-factor-auth" action="/cgi-bin/koha/members/two_factor_auth.pl" method="post"> |
59 |
<form id="two-factor-auth" action="/cgi-bin/koha/members/two_factor_auth.pl" method="post"> |
|
Lines 89-105
Link Here
|
| 89 |
<input type="hidden" name="op" value="disable-2FA" /> |
61 |
<input type="hidden" name="op" value="disable-2FA" /> |
| 90 |
<input type="submit" value="Disable two-factor authentication" /> |
62 |
<input type="submit" value="Disable two-factor authentication" /> |
| 91 |
</form> |
63 |
</form> |
|
|
64 |
</div> |
| 65 |
|
| 66 |
[% IF patron.auth_method == "password" %] |
| 67 |
<div id="registration-status-disabled"> |
| 92 |
[% ELSE %] |
68 |
[% ELSE %] |
|
|
69 |
<div id="registration-status-disabled" style="display: none;"> |
| 70 |
[% END %] |
| 93 |
<div class="two-factor-status">Status: Disabled</div> |
71 |
<div class="two-factor-status">Status: Disabled</div> |
|
|
72 |
[% IF Koha.Preference('TwoFactorAuthentication') == 'enforced' %] |
| 73 |
<div>Two-factor authentication is mandatory to login. If you do not enable now it will be asked at your next login.</div> |
| 74 |
[% END %] |
| 94 |
|
75 |
|
| 95 |
<form id="two-factor-auth" action="/cgi-bin/koha/members/two_factor_auth.pl" method="post"> |
76 |
<input id="enable-2FA" type="submit" value="Enable two-factor authentication" /> |
| 96 |
<input type="hidden" name="csrf_token" value="[% csrf_token | html %]" /> |
77 |
</div> |
| 97 |
<input type="hidden" name="op" value="enable-2FA" /> |
78 |
</div> |
| 98 |
<input type="submit" value="Enable two-factor authentication" /> |
|
|
| 99 |
</form> |
| 100 |
|
| 101 |
[% END %] |
| 102 |
[% END %] |
| 103 |
[% END %] |
79 |
[% END %] |
| 104 |
</main> |
80 |
</main> |
| 105 |
</div> <!-- /.col-sm-10.col-sm-push-2 --> |
81 |
</div> <!-- /.col-sm-10.col-sm-push-2 --> |
|
Lines 117-125
Link Here
|
| 117 |
[% Asset.js("js/members-menu.js") | $raw %] |
93 |
[% Asset.js("js/members-menu.js") | $raw %] |
| 118 |
<script> |
94 |
<script> |
| 119 |
$(document).ready(function(){ |
95 |
$(document).ready(function(){ |
| 120 |
$(".delete").on("click", function(e){ |
96 |
$("#enable-2FA").on("click", function(e){ |
| 121 |
return confirmDelete(_("Are you sure you want to delete this key?")); |
97 |
e.preventDefault(); |
|
|
98 |
$.ajax({ |
| 99 |
data: {}, |
| 100 |
type: 'POST', |
| 101 |
url: '/api/v1/auth/two-factor/registration', |
| 102 |
success: function (data) { |
| 103 |
$("#qr_code").attr('src', data.qr_code); |
| 104 |
$("#secret32").val(data.secret32); |
| 105 |
$("#issuer").html(data.issuer); |
| 106 |
$("#key_id").html(data.key_id); |
| 107 |
$("#registration-form").show(); |
| 108 |
$("#registration-status").hide(); |
| 109 |
}, |
| 110 |
error: function (data) { |
| 111 |
alert(data); |
| 112 |
}, |
| 113 |
}); |
| 122 |
}); |
114 |
}); |
|
|
115 |
|
| 116 |
$("#register-2FA").on("click", function(e){ |
| 117 |
e.preventDefault(); |
| 118 |
const data = { |
| 119 |
secret32: $("#secret32").val(), |
| 120 |
pin_code: $("#pin_code").val(), |
| 121 |
}; |
| 122 |
if (!data.pin_code) return; |
| 123 |
|
| 124 |
$.ajax({ |
| 125 |
data: data, |
| 126 |
type: 'POST', |
| 127 |
url: '/api/v1/auth/two-factor/registration/verification', |
| 128 |
success: function (data) { |
| 129 |
window.location = "/cgi-bin/koha/members/two_factor_auth.pl"; |
| 130 |
}, |
| 131 |
error: function (data) { |
| 132 |
const error = data.responseJSON.error; |
| 133 |
if ( error == 'Invalid pin' ) { |
| 134 |
$("#errors").html(_("Invalid PIN code")).show(); |
| 135 |
} else { |
| 136 |
alert(error); |
| 137 |
} |
| 138 |
}, |
| 139 |
}); |
| 140 |
}); |
| 141 |
|
| 123 |
}); |
142 |
}); |
| 124 |
</script> |
143 |
</script> |
| 125 |
[% END %] |
144 |
[% END %] |