Bug 17047: SQL reports management with Mana-KB
[koha.git] / svc / mana / token
1 #!/usr/bin/perl
2
3 # Copyright 2016 BibLibre Baptiste Wojtkowski
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
19 #
20
21
22 use Modern::Perl;
23
24 use Koha::SharedContent;
25 use C4::Auth qw(check_cookie_auth);
26
27 use CGI;
28 use JSON;
29
30 my $input = new CGI;
31 binmode STDOUT, ":encoding(UTF-8)";
32 print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
33
34 my ( $auth_status, $sessionID ) =
35   check_cookie_auth( $input->cookie('CGISESSID'),
36     { serials => 'create_subscription' } );
37
38 if ( $auth_status ne "ok" ) {
39     exit 0;
40 }
41
42 my $mana_ip = C4::Context->config('mana_config');
43
44 my $url = "$mana_ip/getsecuritytoken";
45 my $request = HTTP::Request->new( POST => $url );
46
47 my $content;
48 $content->{ firstname }= $input->param("firstname");
49 $content->{ lastname }= $input->param("lastname");
50 $content->{ email }= $input->param("email");
51 my $json = to_json( $content, { utf8 => 1 } );
52 $request->content($json);
53 my $result = Koha::SharedContent::process_request($request);
54
55 print(to_json($result));