From 01556e1128f60bd3252d6f31c73eeb797bec9d98 Mon Sep 17 00:00:00 2001 From: einhverfr Date: Thu, 1 Nov 2007 22:06:34 +0000 Subject: 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 --- LedgerSMB.pm | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) (limited to 'LedgerSMB.pm') 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}; -- cgit v1.2.3