From ebbdacfb7cbe31ca917e3f115ff6913d85a439a3 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 18 Sep 2014 14:54:08 +0000 Subject: consistent return value scheme diff --git a/authtoken.json b/authtoken.json index c080028..2db49de 100755 --- a/authtoken.json +++ b/authtoken.json @@ -14,6 +14,7 @@ if(defined $ENV{REMOTE_USER}) { ($dbh, $status, $errorstring) = rddb::opendb(); if(defined $dbh) { ($token, $status, $errorstring) = rddb::get_token($dbh, $ENV{REMOTE_USER}); + $token = '' unless($token); $username = $ENV{REMOTE_USER}; rddb::closedb($dbh); } diff --git a/lib/rddb.pm b/lib/rddb.pm index c12ea26..7767fde 100755 --- a/lib/rddb.pm +++ b/lib/rddb.pm @@ -35,16 +35,16 @@ sub get_token my ($dbh, $username) = @_; my $sth = $dbh->prepare('select PASSWORD from USERS where LOGIN_NAME = ?') - or return ('', 'ERROR', "Database Error: " . $dbh->errstr); + or return (undef, 'ERROR', "Database Error: " . $dbh->errstr); $sth->execute($username) - or return ('', 'ERROR', "Database Error: " . $sth->errstr); + or return (undef, 'ERROR', "Database Error: " . $sth->errstr); my ($token) = $sth->fetchrow_array; $sth->finish(); unless(defined $token) { - return ('', 'ERROR', "user '" . $username . "' not known by rivendell") + return (undef, 'ERROR', "user '" . $username . "' not known by rivendell") } return ($token, 'OK', 'success'); } -- cgit v0.10.2