summaryrefslogtreecommitdiff
path: root/LedgerSMB.pm
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-11-01 22:06:34 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-11-01 22:06:34 +0000
commit01556e1128f60bd3252d6f31c73eeb797bec9d98 (patch)
tree6ff1babfb6c40b366f1cb20c08a2d14adb1eda2c /LedgerSMB.pm
parent276e52fe93b5090c51aa18746d66bf1d39cd0920 (diff)
Moving Auth functions into Session handler
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1834 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB.pm')
-rwxr-xr-xLedgerSMB.pm34
1 files changed, 5 insertions, 29 deletions
diff --git a/LedgerSMB.pm b/LedgerSMB.pm
index 96006b62..81e34759 100755
--- a/LedgerSMB.pm
+++ b/LedgerSMB.pm
@@ -215,27 +215,7 @@ sub new {
sub _get_password {
my ($self) = shift @_;
$self->{sessionexpired} = shift @_;
- $self->{hidden} = [];
- for (keys %$self){
- next if $_ =~ /(^script$|^endsession$|^password$|^hidden$)/;
- my $attr = {};
- $attr->{name} = $_;
- $attr->{value} = $self->{$_};
- push @{$self->{hidden}}, $attr;
- }
- print "WWW-Authenticate: Basic realm=\"LedgerSMB\"\n";
- print "Status: 401 Unauthorized\n\n";
- print "Please enter your credentials.\n";
- exit;
-# my $template = LedgerSMB::Template->new(
-# user =>$self->{_user},
-# locale => $self->{_locale},
-# path => 'UI',
-# template => 'get_password',
-# format => 'HTML'
-# );
-# $template->render($self);
-# $template->output('http');
+ Session::credential_prompt();
exit;
}
@@ -654,13 +634,9 @@ sub _db_init {
my $self = shift @_;
my %args = @_;
-
- # Handling of HTTP Basic Auth headers
- my $auth = $ENV{'HTTP_AUTHORIZATION'};
- $auth =~ s/Basic //i; # strip out basic authentication preface
- $auth = MIME::Base64::decode($auth);
- my ($login, $password) = split(/:/, $auth);
- $self->{login} = $login;
+ my $creds = Session::get_credentials();
+
+ $self->{login} = $creds->{login};
if (!$self->{company}){
$self->{company} = $LedgerSMB::Sysconfig::default_db;
}
@@ -671,7 +647,7 @@ sub _db_init {
# Just in case, however, I think it is a good idea to include the DBI
# error string. CT
$self->{dbh} = DBI->connect(
- "dbi:Pg:dbname=$dbname", "$login", "$password", { AutoCommit => 0 }
+ "dbi:Pg:dbname=$dbname", "$creds->{login}", "$creds->{password}", { AutoCommit => 0 }
);
my $dbh = $self->{dbh};