From 0050db6cb376a40d930f2460f568d7ac8363d0ca Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Jul 14 2017 10:54:17 +0000 Subject: Aesthetic code changes --- diff --git a/lib/Lufi.pm b/lib/Lufi.pm index ac49347..dd0e878 100755 --- a/lib/Lufi.pm +++ b/lib/Lufi.pm @@ -11,7 +11,7 @@ $ENV{MOJO_MAX_WEBSOCKET_SIZE} = 100485760; # 10 * 1024 * 1024 = 10MiB # This method will run once at server start sub startup { my $self = shift; - my $entry = undef; + my $entry; my $config = $self->plugin('Config' => { default => { @@ -85,14 +85,14 @@ sub startup { my $mesg = $ldap->bind($c->config->{ldap}->{bind_user}.$c->config->{ldap}->{bind_dn}, password => $c->config->{ldap}->{bind_pwd} ); - + $mesg->code && die $mesg->error; - + $mesg = $ldap->search( base => $c->config->{ldap}->{user_tree}, filter => "(&(uid=$username)".$c->config->{ldap}->{user_filter}.")" ); - + if ($mesg->code) { $c->app->log->error($mesg->error); return undef; @@ -104,18 +104,18 @@ sub startup { $c->app->log->info("[LDAP authentication failed] - User $username filtered out, IP: ".$c->ip); return undef; } - + # Now we know that the user exists, and that he is authorized by the filter $mesg = $ldap->bind('uid='.$username.$c->config->{ldap}->{bind_dn}, password => $password ); - + if ($mesg->code) { $c->app->log->info("[LDAP authentication failed] login: $username, IP: ".$c->ip); $c->app->log->error("[LDAP authentication failed] ".$mesg->error); return undef; } - + $c->app->log->info("[LDAP authentication successful] login: $username, IP: ".$c->ip); } elsif (defined($c->config('htpasswd'))) { my $htpasswd = new Apache::Htpasswd({passwdFile => $c->config->{htpasswd}, @@ -296,7 +296,7 @@ sub startup { if($c->authenticate($login, $pwd)) { $c->redirect_to('index'); - } elsif (defined $entry) { + } elsif (defined $entry) { $c->stash(msg => $c->l('Please, check your credentials: unable to authenticate.')); $c->render(template => 'login'); } else {