blob: 61b06c554b91c725cbd1ede51a51f6b615437956 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#! /usr/bin/env perl
# Copyright 2012, Matthias Andreas Benkard <code@mail.matthias.benkard.de>.
use common::sense;
use Modern::Perl;
use JSON;
use File::Slurp;
use CGI;
use CGI::Fast;
use CGI::Session;
do "common.pl";
while (my $cgi = new CGI::Fast) {
local $::MULKONF = { };
do "config.pl";
print $cgi->header(-content_type => 'application/json; charset=UTF-8');
my $cookie = $cgi->cookie('mulkid_session');
unless ($cookie) {
say encode_json({logged_in_p => 0});
exit(0);
}
my $session = new CGI::Session("driver:File", $cookie, {Directory=>"/tmp"});
unless ($session) {
say encode_json({logged_in_p => 0});
exit(0);
}
my $email = $cgi->param('email') or die "No email address supplied";
my $session_user = $session->param('user');
if ($session_user ~~ email_users($::MULKONF, $email)) {
say encode_json({logged_in_p => 1});
} else {
say encode_json({logged_in_p => 0});
}
}
|