Users using the Tequila login are invited to migrate to gitlab.epfl.ch. This instance will close for Tequila users by May 2020.

Commit 19f46af0 authored by Florian Vessaz's avatar Florian Vessaz

Lots of fixes

parent 0a15c12d
......@@ -112,7 +112,7 @@ sub contains {
if (ref $user) {
$user = $user->username;
}
return grep {$_ eq $user} $self->{usernames};
return grep {$_ eq $user} @{$self->{usernames}};
}
1;
......@@ -366,11 +366,11 @@ sub _add_host_permissions {
. "(memberUid=" . escape_filter_value($member->{username}) . ")"
. "(|$group_filters))";
my $mesg = $ldap->search(
base => $GnuGeneration::LDAP->GROUPS_BASE,
base => $GnuGeneration::LDAP::GROUPS_BASE,
filter => $filter,
attrs => ['cn']);
warn "LDAP search failed", $mesg->error if $mesg->code;
while ($mesg->pop_entry) {
foreach ($mesg->entries) {
my $group = $_->get_value("cn");
$group =~ /^(.*)-(login|sudoers)$/;
if ($2 eq "login") {
......
use Dancer ':syntax';
use strict;
use warnings 'FATAL' => 'all';
our $VERSION = '0.1';
use Email::Valid;
......@@ -7,11 +10,12 @@ use Data::Dumper;
use EPFL::People;
use GnuGeneration::Member;
use GnuGeneration::Group;
use PasswordToken;
use mail;
GnuGeneration::Member->admin_credentials(
GnuGeneration::LDAP->credentials(
dn => config->{ldap_admin_dn},
password => config->{ldap_admin_password});
......@@ -78,7 +82,7 @@ hook 'before' => sub {
return redirect "/login";
} elsif (not defined session 'timestamp'
or (session 'timestamp') < time - config->{session_expire}) {
info "Session of " . session 'username' . " has expired.";
info "Session of " . session('username') . " has expired.";
session 'redirect' => request->path_info;
return redirect "/session_expired";
} else {
......@@ -120,17 +124,22 @@ post '/login' => sub {
redirect 'login';
};
any '/session_expired' => sub {
sub logout {
session 'username' => undef;
session 'admin' => undef;
session->destroy;
}
any '/session_expired' => sub {
info session('username') . "logged out due to expired session.";
logout;
template 'session_expired';
};
get '/logout' => sub {
info session 'username' . " logs out.";
session 'username' => undef;
session->destroy;
info session('username') . " logs out.";
logout;
redirect '/';
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment