Bug 17047: SQL reports management with Mana-KB
[koha.git] / svc / mana / token
blob3ea62543584d42d43771f0e98be46e7f000a45ab
1 #!/usr/bin/perl
3 # Copyright 2016 BibLibre Baptiste Wojtkowski
5 # This file is part of Koha.
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.
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.
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>.
22 use Modern::Perl;
24 use Koha::SharedContent;
25 use C4::Auth qw(check_cookie_auth);
27 use CGI;
28 use JSON;
30 my $input = new CGI;
31 binmode STDOUT, ":encoding(UTF-8)";
32 print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
34 my ( $auth_status, $sessionID ) =
35 check_cookie_auth( $input->cookie('CGISESSID'),
36 { serials => 'create_subscription' } );
38 if ( $auth_status ne "ok" ) {
39 exit 0;
42 my $mana_ip = C4::Context->config('mana_config');
44 my $url = "$mana_ip/getsecuritytoken";
45 my $request = HTTP::Request->new( POST => $url );
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);
55 print(to_json($result));