Commit 63f19607 authored by Yadd's avatar Yadd
Browse files

LEMONLDAP::NG : die replaced by $self->abort in CGIs

parent ac87a4b4
......@@ -59,6 +59,21 @@ sub header_public {
);
}
sub abort {
my $self = shift;
my $cgi = CGI->new;
my ( $t1, $t2 ) = @_;
$t2 ||= "See Apache's logs";
print $cgi->header('text/html; charset=utf8');
print $cgi->start_html(
-title => $t1,
-encoding => 'utf8',
);
print "<h1>$t1</h1>";
print "<p>$t2</p>";
exit;
}
1;
__END__
......
......@@ -12,21 +12,6 @@ use Lemonldap::NG::Handler::SharedConf qw(:all);
our $VERSION = '0.11';
sub abort {
my $self = shift;
my $cgi = CGI->new;
my ( $t1, $t2 ) = @_;
$t2 ||= "See Apache's logs";
print $cgi->header('text/html; charset=utf8');
print $cgi->start_html(
-title => $t1,
-encoding => 'utf8',
);
print "<h1>$t1</h1>";
print "<p>$t2</p>";
exit;
}
sub new {
my $class = shift;
my $self = $class->SUPER::new() or $class->abort("Unable to build CGI");
......
......@@ -24,7 +24,7 @@ sub new {
my $self;
if ( $args->{protection} ) {
eval 'use Lemonldap::NG::Handler::CGI;';
die($@) if ($@);
$class->abort($@) if ($@);
unshift @ISA, "Lemonldap::NG::Handler::CGI";
$self = $class->SUPER::new($args);
}
......@@ -759,7 +759,7 @@ sub config {
$self->{_config} =
Lemonldap::NG::Common::Conf->new( $self->{configStorage} );
unless ( $self->{_config} ) {
die "Configuration not loaded\n";
$self->abort("Configuration not loaded\n");
}
return $self->{_config};
}
......
......@@ -23,6 +23,7 @@ BEGIN {
my $class = shift;
my $args = shift;
my $data = shift;
# TODO : replace die by abort
my $dbh =
DBI->connect( $args->{DataSource}, $args->{UserName},
$args->{Password} )
......@@ -60,6 +61,7 @@ BEGIN {
my $args = shift;
my $data = shift;
$args->{Directory} ||= '/tmp';
# TODO : replace die by abort
unless ( opendir DIR, $args->{Directory} ) {
die "Cannot open directory $args->{Directory}\n";
}
......@@ -93,6 +95,7 @@ BEGIN {
if ( !tied %{ $class->{dbm} } ) {
my $rv = tie %{ $class->{dbm} }, 'DB_File', $args->{FileName};
# TODO : replace die by abort
if ( !$rv ) {
die "Could not open dbm file " . $args->{FileName} . ": $!";
}
......
......@@ -50,10 +50,10 @@ sub new {
# Get configuration
$self->Lemonldap::NG::Portal::Simple::getConf(@_)
or die "Unable to get configuration";
or $self->abort("Unable to get configuration");
# Portal is required
die("Portal object required") unless ( $self->{portalObject} );
$self->abort("Portal object required") unless ( $self->{portalObject} );
# Fill sessionInfo
&Lemonldap::NG::Portal::Simple::getSessionInfo( $self->{portalObject} );
......
......@@ -71,12 +71,12 @@ our $self; # Safe cannot share a variable declared with my
sub new {
my $class = shift;
my $self = $class->SUPER::new();
$self->getConf(@_) or die "Unable to get configuration";
die("You've to indicate a an Apache::Session storage module !")
$self->getConf(@_) or $self->abort("Unable to get configuration");
$self->abort("You've to indicate a an Apache::Session storage module !")
unless ( $self->{globalStorage} );
eval "require " . $self->{globalStorage};
die( "Module " . $self->{globalStorage} . " not found in \@INC" ) if ($@);
die("You've to indicate a domain for cookies") unless ( $self->{domain} );
$self->abort( "Module " . $self->{globalStorage} . " not found in \@INC" ) if ($@);
$self->abort("You've to indicate a domain for cookies") unless ( $self->{domain} );
$self->{domain} =~ s/^([^\.])/.$1/;
$self->{securedCookie} ||= 0;
$self->{cookieName} ||= "lemonldap";
......@@ -92,7 +92,7 @@ sub new {
. $self->{$_};
$tmp =~ s/\s.*$//;
eval "require $tmp";
die($@) if ($@);
$self->abort($@) if ($@);
push @ISA, $tmp;
# $self->{authentication} and $self->{userDB} can contains arguments
......@@ -433,7 +433,7 @@ sub existingSession {
sub setMacros {
local $self = shift;
die __PACKAGE__ . ": Unable to get configuration"
$self->abort( __PACKAGE__ . ": Unable to get configuration" )
unless ( $self->getConf(@_) );
while ( my ( $n, $e ) = each( %{ $self->{macros} } ) ) {
$e =~ s/\$(\w+)/\$self->{sessionInfo}->{$1}/g;
......
......@@ -85,7 +85,7 @@ sub setSessionInfo {
}
}
else {
die('Only hash reference are supported now in exportedVars');
$self->abort('Only hash reference are supported now in exportedVars');
}
PE_OK;
}
......
......@@ -10,7 +10,7 @@ sub new {
my $portal = shift;
my $self;
unless ($portal) {
die("$class : portal argument required !");
$class->abort("$class : portal argument required !");
}
my $useTls = 0;
my $tlsParam;
......
Supports Markdown
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