Bug 32977: Add callnumber column to boraccount.tt
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / members / two_factor_auth.tt
1 [% USE raw %]
2 [% USE Koha %]
3 [% USE Asset %]
4 [% SET footerjs = 1 %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Two-factor authentication &rsaquo; Patrons &rsaquo; Koha</title>
7 [% INCLUDE 'doc-head-close.inc' %]
8 </head>
9 <body id="pat_two_factor_auth" class="pat">
10 [% WRAPPER 'header.inc' %]
11     [% INCLUDE 'patron-search-header.inc' %]
12 [% END %]
13 [% PROCESS 'auth-two-factor.inc' %]
14
15 [% WRAPPER 'sub-header.inc' %]
16 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
17     <ol>
18         <li>
19             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
20         </li>
21         <li>
22             <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
23         </li>
24         <li>
25             <a href="#" aria-current="page">
26                 Manage two-factor authentication
27             </a>
28         </li>
29     </ol>
30 </nav>
31 [% END %]
32
33 <div class="main container-fluid">
34     <div class="row">
35         <div class="col-sm-10 col-sm-push-2">
36             <main>
37
38                 [% INCLUDE 'members-toolbar.inc' %]
39
40                 <h1>Manage two-factor authentication</h1>
41
42                 [% IF ( missing_key ) %]
43                     <div id="error_message" class="dialog message">
44                         <p>
45                             Operation cannot proceed, please define an encryption key in your configuration.
46                         </p>
47                     </div>
48                 [% ELSE %]
49                     [% PROCESS registration_form %]
50
51                     <div id="registration-status">
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 %]
57                             <div class="two-factor-status">Status: Enabled</div>
58
59                             <form id="two-factor-auth" action="/cgi-bin/koha/members/two_factor_auth.pl" method="post">
60                                 <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
61                                 <input type="hidden" name="op" value="disable-2FA" />
62                                 <input type="submit" value="Disable two-factor authentication" />
63                             </form>
64                         </div>
65
66                         [% IF patron.auth_method == "password" %]
67                         <div id="registration-status-disabled">
68                         [% ELSE %]
69                         <div id="registration-status-disabled" style="display: none;">
70                         [% END %]
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 %]
75
76                             <input id="enable-2FA" type="submit" value="Enable two-factor authentication" />
77                         </div>
78                     </div>
79                 [% END %]
80             </main>
81         </div> <!-- /.col-sm-10.col-sm-push-2 -->
82
83         <div class="col-sm-2 col-sm-pull-10">
84             <aside>
85                 [% INCLUDE 'circ-menu.inc' %]
86             </aside>
87         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
88     </div> <!-- /.row -->
89
90
91 [% MACRO jsinclude BLOCK %]
92     [% INCLUDE 'str/members-menu.inc' %]
93     [% Asset.js("js/members-menu.js") | $raw %]
94     <script>
95         $(document).ready(function(){
96             $("#enable-2FA").on("click", function(e){
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                 });
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
142         });
143     </script>
144 [% END %]
145
146 [% INCLUDE 'intranet-bottom.inc' %]