[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb: [1719] trunk
- Subject: SF.net SVN: ledger-smb: [1719] trunk
- From: ..hidden..
- Date: Sun, 07 Oct 2007 22:19:19 -0700
Revision: 1719
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1719&view=rev
Author: einhverfr
Date: 2007-10-07 22:19:19 -0700 (Sun, 07 Oct 2007)
Log Message:
-----------
A few untested authentication fixes to legacy code
Modified Paths:
--------------
trunk/LedgerSMB/Form.pm
trunk/LedgerSMB.pm
Modified: trunk/LedgerSMB/Form.pm
===================================================================
--- trunk/LedgerSMB/Form.pm 2007-10-08 05:04:21 UTC (rev 1718)
+++ trunk/LedgerSMB/Form.pm 2007-10-08 05:19:19 UTC (rev 1719)
@@ -115,6 +115,19 @@
}
$self->{login} =~ s/[^a-zA-Z0-9._+\@'-]//g;
+ if (!$self->{company} && $ENV{HTTP_COOKIE}){
+ $ENV{HTTP_COOKIE} =~ s/;\s*/;/g;
+ my %cookie;
+ my @cookies = split /;/, $ENV{HTTP_COOKIE};
+ foreach (@cookies) {
+ my ( $name, $value ) = split /=/, $_, 2;
+ $cookie{$name} = $value;
+ }
+ my $ccookie = $cookie{LedgerSMB};
+ $ccookie =~ s/.*:([^:]*)$/$1/;
+ $self->{company} = $ccookie;
+ }
+
$self->{menubar} = 1 if $self->{path} =~ /lynx/i;
#menubar will be deprecated, replaced with below
@@ -1119,8 +1132,14 @@
$auth =~ s/Basic //i; # strip out basic authentication preface
$auth = MIME::Base64::decode($auth);
my ($login, $password) = split(/:/, $auth);
+ $self->{login} = $login;
+ if (!$self->{company}){
+ $self->{company} = $LedgerSMB::Sysconfig::default_db;
+ }
+ my $dbname = $self->{company};
$self->{dbh} = $self->dbconnect_noauto($myconfig) || $self->dberror();
+ my $dbh = $self->{dbh};
my %date_query = (
'mm/dd/yy' => 'set DateStyle to \'SQL, US\'',
@@ -1133,6 +1152,16 @@
$self->{dbh}->do( $date_query{ $myconfig->{dateformat} } );
$self->{db_dateformat} = $myconfig->{dateformat}; #shim
+ # This is the general version check
+ my $sth = $dbh->prepare("
+ SELECT value FROM defaults
+ WHERE setting_key = 'version'");
+ $sth->execute;
+ my ($dbversion) = $sth->fetchrow_array;
+ if ($dbversion ne $self->{dbversion}){
+ $self->error("Database is not the expected version.");
+ }
+
my $query = "SELECT t.extends,
coalesce (t.table_name, 'custom_' || extends)
|| ':' || f.field_name as field_def
Modified: trunk/LedgerSMB.pm
===================================================================
--- trunk/LedgerSMB.pm 2007-10-08 05:04:21 UTC (rev 1718)
+++ trunk/LedgerSMB.pm 2007-10-08 05:19:19 UTC (rev 1719)
@@ -649,7 +649,6 @@
my $self = shift @_;
my %args = @_;
- $self->debug({file => '/tmp/dbconnect'});
# Handling of HTTP Basic Auth headers
my $auth = $ENV{'HTTP_AUTHORIZATION'};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.