summaryrefslogtreecommitdiff
path: root/LedgerSMB/User.pm
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-10-07 06:07:18 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-10-07 06:07:18 +0000
commit2c60683b106fad0c3410ba30d669679955508958 (patch)
tree905a87d19e5ba5dd264ac7fef3a6c493d81506b6 /LedgerSMB/User.pm
parent297c220ffce8d03f2ca8a196336d47d3754ce95c (diff)
Login is still broken. However, a lot of progress has been made. THis also includes the COGS changes made since 1.2.8
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1712 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB/User.pm')
-rw-r--r--LedgerSMB/User.pm100
1 files changed, 4 insertions, 96 deletions
diff --git a/LedgerSMB/User.pm b/LedgerSMB/User.pm
index 89033ed1..41aa0dcd 100644
--- a/LedgerSMB/User.pm
+++ b/LedgerSMB/User.pm
@@ -165,14 +165,15 @@ sub fetch_config {
#I'm hoping that this function will go and is a temporary bridge
#until we get rid of %myconfig elsewhere in the code
- my ( $self, $login ) = @_;
+ my ( $self, $lsmb ) = @_;
+
+ my $login = $lsmb->{login};
+ my $dbh = $lsmb->{dbh};
if ( !$login ) {
&error( $self, "Access Denied" );
}
- # use central db
- my $dbh = ${LedgerSMB::Sysconfig::GLOBALDBH};
# for now, this is querying the table directly... ugly
# my $fetchUserPrefs = $dbh->prepare(
@@ -230,99 +231,6 @@ sub fetch_config {
return \%myconfig;
}
-=item $user->login($form);
-
-Disused auth function.
-
-=cut
-
-sub login {
-
- my ( $self, $form ) = @_;
-
- my $rc = -1;
-
- if ( $self->{login} ne "" ) {
- if (
- !Session::password_check(
- $form, $form->{login}, $form->{password}
- )
- )
- {
- return -1;
- }
-
- #this is really dumb, but %myconfig will have to stay until 1.3
- while ( my ( $key, $value ) = each( %{$self} ) ) {
- $myconfig{$key} = $value;
- }
-
- # check if database is down
- my $dbh =
- DBI->connect( $myconfig{dbconnect}, $myconfig{dbuser},
- $myconfig{dbpasswd} )
- or $self->error( __FILE__ . ':' . __LINE__ . ': ' . $DBI::errstr );
- $dbh->{pg_enable_utf8} = 1;
-
- # we got a connection, check the version
- my $query = qq|
- SELECT value FROM defaults
- WHERE setting_key = 'version'|;
- my $sth = $dbh->prepare($query);
- $sth->execute || $form->dberror( __FILE__ . ':' . __LINE__ . $query );
-
- my ($dbversion) = $sth->fetchrow_array;
- $sth->finish;
-
- # add login to employee table if it does not exist
- # no error check for employee table, ignore if it does not exist
- my $login = $self->{login};
- $login =~ s/@.*//;
- $query = qq|SELECT entity_id FROM employee WHERE login = ?|;
- $sth = $dbh->prepare($query);
- $sth->execute($login);
-
- my ($id) = $sth->fetchrow_array;
- $sth->finish;
-
- if ( !$id ) {
- my ($employeenumber) =
- $form->update_defaults( \%myconfig, "employeenumber", $dbh );
-
- $query = qq|
- INSERT INTO employee
- (login, employeenumber, name,
- workphone, role)
- VALUES (?, ?, ?, ?, ?)|;
- $sth = $dbh->prepare($query);
- $sth->execute(
- $login, $employeenumber, $myconfig{name},
- $myconfig{tel}, $myconfig{role}
- );
- }
- $dbh->disconnect;
-
- $rc = 0;
-
- if ( $form->{dbversion} ne $dbversion ) {
- $rc = -3;
- $dbupdate =
- ( calc_version($dbversion) < calc_version( $form->{dbversion} ) );
- }
-
- if ($dbupdate) {
- $rc = -4;
-
- # if DB2 bale out
- if ( $myconfig{dbdriver} eq 'DB2' ) {
- $rc = -2;
- }
- }
- }
-
- $rc;
-
-}
=item LedgerSMB::User->check_recurring($form);