Bug 20568: CSRF protection
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / members / apikeys.tt
1 [% USE Koha %]
2 [% SET footerjs = 1 %]
3 [% INCLUDE 'doc-head-open.inc' %]
4 <title>Koha &rsaquo; Patrons &rsaquo; API Keys</title>
5 [% INCLUDE 'doc-head-close.inc' %]
6 </head>
7 <body id="pat_apikeys" class="pat">
8 [% INCLUDE 'header.inc' %]
9 [% INCLUDE 'patron-search.inc' %]
10
11 <div id="breadcrumbs">
12     <a href="/cgi-bin/koha/mainpage.pl">Home</a>
13     &rsaquo;
14     <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
15     &rsaquo;
16     API Keys for [% INCLUDE 'patron-title.inc' %]
17 </div>
18
19 <div id="doc3" class="yui-t2">
20     <div id="bd">
21         <div id="yui-main">
22             <div class="yui-b">
23                 [% INCLUDE 'members-toolbar.inc' %]
24
25                 <h1>API keys for [% INCLUDE 'patron-title.inc' %]</h1>
26                 <form id="add-api-key" action="/cgi-bin/koha/members/apikeys.pl" method="post" style="display:none">
27                     <input type="hidden" name="patron_id" value="[% patron.id %]" />
28                     <input type="hidden" name="csrf_token" value="[% csrf_token %]" />
29                     <input type="hidden" name="op" value="generate" />
30                     <fieldset class="brief">
31                         <legend>Generate new client id/secret pair</legend>
32                         <ol>
33                             <li>
34                                 <label for="description">Description: </label>
35                                 <input type="text" name="description" />
36                                 <input type="submit" value="Save" />
37                                 <a href="#" class="cancel toggle_element" data-element="#add-api-key">Cancel</a>
38                             </li>
39                         </ol>
40                     </fieldset>
41                 </form>
42
43                 <div id="keys">
44                     [% IF api_keys && api_keys.size > 0 %]
45                         <p>
46                             <button class="btn btn-default btn-xs toggle_element" type="submit" id="show-api-form" data-element="#add-api-key"><i class="fa fa-plus"></i> Generate a new client id/key pair</button>
47                         </p>
48                         <table>
49                             <thead>
50                                 <tr>
51                                     <th>Description</th>
52                                     <th>Client ID</th>
53                                     <th>Secret</th>
54                                     <th>Active</th>
55                                     <th>Actions</th>
56                                 </tr>
57                             </thead>
58                             <tbody>
59                                 [% FOREACH key IN api_keys %]
60                                     <tr>
61                                         <td>[% key.description %]</td>
62                                         <td>[% key.client_id %]</td>
63                                         <td>[% key.secret %]</td>
64                                         <td>[% IF key.active %]Yes[% ELSE %]No[% END %]</td>
65                                         <td>
66                                             <form action="/cgi-bin/koha/members/apikeys.pl" method="post">
67                                                 <input type="hidden" name="patron_id" value="[% patron.id %]" />
68                                                 <input type="hidden" name="key" value="[% key.id %]" />
69                                                 <input type="hidden" name="csrf_token" value="[% csrf_token %]" />
70                                                 <input type="hidden" name="op" value="delete" />
71                                                 <button class="btn btn-default btn-xs delete" type="submit"><i class="fa fa-trash"></i> Delete</button>
72                                             </form>
73                                             <form action="/cgi-bin/koha/members/apikeys.pl" method="post">
74                                                 <input type="hidden" name="patron_id" value="[% patron.id %]" />
75                                                 <input type="hidden" name="key" value="[% key.id %]" />
76                                                 <input type="hidden" name="csrf_token" value="[% csrf_token %]" />
77                                                 [% IF key.active %]
78                                                     <input type="hidden" name="op" value="revoke" />
79                                                     <button class="btn btn-default btn-xs" type="submit"><i class="fa fa-remove"></i> Revoke</button>
80                                                 [% ELSE %]
81                                                     <input type="hidden" name="op" value="activate" />
82                                                     <button class="btn btn-default btn-xs" type="submit"><i class="fa fa-play"></i> Activate</button>
83                                                 [% END %]
84                                             </form>
85                                         </td>
86                                     </tr>
87                                 [% END %]
88                             </tbody>
89                         </table>
90                     [% ELSE %]
91                         <div class="dialog message">No keys defined for the current patron. <a href="#" class="toggle_element" data-element="#add-api-key" id="show-api-form"><i class="fa fa-plus"></i> Generate a new client id/secret pair</div>
92                     [% END %]
93                 </div>
94             </div>
95         </div>
96         <div class="yui-b">
97             [% INCLUDE 'circ-menu.inc' %]
98         </div>
99     </div>
100
101 [% MACRO jsinclude BLOCK %]
102         <script>
103             $(document).ready(function(){
104                 $(".delete").on("click", function(e){
105                     return confirmDelete(_("Are you sure you want to delete this key?"));
106                 });
107             });
108         </script>
109 [% END %]
110
111 [% INCLUDE 'intranet-bottom.inc' %]