aboutsummaryrefslogtreecommitdiff
path: root/www/login.pl
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2014-05-05 14:36:43 +0200
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2014-05-13 21:07:24 +0200
commit0db96cce9f83f09b07a46f31f9930e5b7cc19f6f (patch)
tree577ed4c85e1346193b5fe5e4e6fef0a4abb77d87 /www/login.pl
parentd8907f11f5c255727b8a814746a0114e5c62e30a (diff)
Fix bugs introduced by the previous patch.
Diffstat (limited to 'www/login.pl')
-rwxr-xr-xwww/login.pl36
1 files changed, 10 insertions, 26 deletions
diff --git a/www/login.pl b/www/login.pl
index a2f06c4..1b196fa 100755
--- a/www/login.pl
+++ b/www/login.pl
@@ -39,40 +39,24 @@ sub check_imap_password($$) {
while (my $cgi = new CGI::Fast) {
- load_config;
+ load_config();
my $cookie = $cgi->cookie('mulkid_session');
- my $session;
- if ($cookie) {
- $session = new CGI::Session("driver:File", $cookie, {Directory=>"/tmp"});
- print $cgi->header(-content_type => 'application/json; charset=UTF-8');
- } else {
- $session = new CGI::Session("driver:File", undef, {Directory=>"/tmp"});
- my $cookie = $cgi->cookie(-name => 'mulkid_session',
- -value => $session->id,
- -expires => '+1d',
- -secure => 1,
- -httponly => 1,
- #-domain => '.mulk.eu'
- );
- print $cgi->header(-content_type => 'application/json; charset=UTF-8',
- -cookie => $cookie);
- }
-
- my $email = $cgi->param('email') or die "No email address provided";
-
- for ($::MULKONF->{auth_type}) {
+ my $session = new CGI::Session("driver:File", $cookie, {Directory=>"/tmp"});
+ given (my $_ = $::MULKONF->{auth_type}) {
when ('imap') {
+ my $email = $cgi->param('email') or die "No email address provided";
my $password = $cgi->param('password') or die "Empty password";
for my $user (email_users($email)) {
#say STDERR "Trying user: $user";
if (check_imap_password($user, $password)) {
$session->param('user', $user);
- #say encode_json({user => $user});
- print $cgi->redirect(-url => reluri($cgi, 'successful-login.html'));
+ print $cgi->header(-content_type => 'application/json; charset=UTF-8');
+ say encode_json({user => $user});
exit 0;
}
}
+ die "Could not authenticate.";
}
when ('google') {
my $g = Net::Google::FederatedLogin->new(
@@ -82,8 +66,10 @@ while (my $cgi = new CGI::Fast) {
$g->verify_auth or die "Could not verify the OpenID assertion!";
my $ext = $g->get_extension('http://openid.net/srv/ax/1.0');
my $verified_email = $ext->get_parameter('value.email');
+ my $fakedomain = $::MULKONF->{fake_domain};
+ my $realdomain = $::MULKONF->{real_domain};
+ $verified_email =~ s/\@$realdomain/\@$fakedomain/ if $fakedomain;
$session->param('user', $verified_email);
- #say encode_json({user => $user});
print $cgi->redirect(-url => reluri($cgi, 'successful-login.html'));
exit 0;
}
@@ -91,6 +77,4 @@ while (my $cgi = new CGI::Fast) {
die "Invalid auth_type. Check MulkyID configuration!";
}
}
-
- die "Could not authenticate.";
}