[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[2840] trunk



Revision: 2840
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2840&view=rev
Author:   einhverfr
Date:     2010-01-22 20:26:09 +0000 (Fri, 22 Jan 2010)

Log Message:
-----------
New old password field added, spec updated, and checks added regarding db vs user auth errors.  Furthermore added SSL options for db connection.

Modified Paths:
--------------
    trunk/INSTALL
    trunk/LedgerSMB/DBObject/User.pm
    trunk/LedgerSMB/Sysconfig.pm
    trunk/UI/users/preferences.html
    trunk/dists/rpm/ledgersmb.spec
    trunk/ledgersmb.conf.default
    trunk/scripts/login.pl

Modified: trunk/INSTALL
===================================================================
--- trunk/INSTALL	2010-01-22 20:12:54 UTC (rev 2839)
+++ trunk/INSTALL	2010-01-22 20:26:09 UTC (rev 2840)
@@ -332,7 +332,7 @@
 
 Using the psql console, insert myuser to the entity table.
 
-$ psql -U postgres -d mycompany -t -c "INSERT INTO entity (name, entity_class, created) VALUES ('myuser', 3, NOW()) RETURNING name, entity_class, created;"
+$ psql -U postgres -d mycompany -t -c "INSERT INTO entity (name, entity_class, created, country_id) VALUES ('myuser', 3, NOW(), '232') RETURNING name, entity_class, created;"
  myuser |            3 | 2009-04-13
 
 INSERT 0 1
@@ -343,7 +343,7 @@
 
 Insert the myuser entity into the person table:
 
-$ psql -U postgres -d mycompany -t -c "INSERT INTO person (entity_id, first_name, last_name, created,country_id) VALUES (2, 'Firstname', 'Lastname', NOW(),'232') RETURNING entity_id, first_name, last_name, created;"
+$ psql -U postgres -d mycompany -t -c "INSERT INTO person (entity_id, first_name, last_name, created) VALUES (2, 'Firstname', 'Lastname', NOW()) RETURNING entity_id, first_name, last_name, created;"
          2 | Firstname  | Lastname  | 2009-04-13
 
 INSERT 0 1

Modified: trunk/LedgerSMB/DBObject/User.pm
===================================================================
--- trunk/LedgerSMB/DBObject/User.pm	2010-01-22 20:12:54 UTC (rev 2839)
+++ trunk/LedgerSMB/DBObject/User.pm	2010-01-22 20:26:09 UTC (rev 2840)
@@ -46,7 +46,25 @@
 }
 
 sub change_my_password {
+    use LedgerSMB::Auth;
     my ($self) = @_;
+    my $old_dbh = $self->{dbh};
+
+    my $creds = LedgerSMB::Auth::get_credentials();
+  
+    $self->{login} = $creds->{login};
+    my $dbname = $self->{company};
+
+    # Note that we have to request the login/password again if the db
+    # connection fails since this probably means bad credentials are entered.
+    # 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", "$self->{login}", "$self->{old_password}", { AutoCommit => 0 }
+    ); 
+    if (!$self->{dbh}){
+        $self->error($self->{_locale}->text('Incorrect Password'));
+    }
     if ($self->{new_password} ne $self->{confirm_password}){
         $self->error($self->{_locale}->text('Passwords must match.'));
         die;
@@ -54,6 +72,8 @@
     $self->{password} = $self->{new_password};
     $self->exec_method(funcname => 'user__change_password');
     $self->{dbh}->commit;
+    $self->{dbh}->disconnect;
+    $self->{dbh} = $old_dbh;
 }
 
 

Modified: trunk/LedgerSMB/Sysconfig.pm
===================================================================
--- trunk/LedgerSMB/Sysconfig.pm	2010-01-22 20:12:54 UTC (rev 2839)
+++ trunk/LedgerSMB/Sysconfig.pm	2010-01-22 20:26:09 UTC (rev 2840)
@@ -80,6 +80,8 @@
 # Path to the translation files
 $localepath = 'locale/po';
 
+$no_db_str = 'database';
+
 # available printers
 %printer;
 
@@ -90,7 +92,7 @@
 for $var (
     qw(pathsep logging check_max_invoices language auth latex
     db_autoupdate force_username_case max_post_size decimal_places cookie_name
-    return_accno)
+    return_accno no_db_str)
   )
 {
     ${$var} = $config{''}{$var} if $config{''}{$var};
@@ -147,5 +149,5 @@
 $ENV{PGPORT} = $config{database}{port};
 our $default_db = $config{database}{default_db};
 our $db_namespace = $config{database}{db_namespace};
-
+$ENV{PGSSLMODE} = $config{database}{sslmode} if $config{database}{sslmode};
 1;

Modified: trunk/UI/users/preferences.html
===================================================================
--- trunk/UI/users/preferences.html	2010-01-22 20:12:54 UTC (rev 2839)
+++ trunk/UI/users/preferences.html	2010-01-22 20:26:09 UTC (rev 2840)
@@ -17,6 +17,10 @@
 	  <td>
 	    <table>
 	      <tr>
+		<th align="right"><?lsmb text('Old Password') ?></th>
+		<td><input type="password" name="old_password" size="10" value="" /></td>
+	      </tr>
+	      <tr>
 		<th align="right"><?lsmb text('Password') ?></th>
 		<td><input type="password" name="new_password" size="10" value="" /></td>
 	      </tr>

Modified: trunk/dists/rpm/ledgersmb.spec
===================================================================
--- trunk/dists/rpm/ledgersmb.spec	2010-01-22 20:12:54 UTC (rev 2839)
+++ trunk/dists/rpm/ledgersmb.spec	2010-01-22 20:26:09 UTC (rev 2840)
@@ -13,6 +13,7 @@
 Requires: perl-DBD-Pg, perl-DBI >= 1.48, perl-version, perl-Smart-Comments
 Requires: perl-MIME-Lite, perl-Class-Std >= 0.0.8
 Requires: perl-Config-Std >= 0.0.4, perl-Locale-Maketext-Lexicon >= 0.62
+Requires: perl-IO-String
 BuildRequires: perl
 # avoid bogus autodetection of perl modules:
 AutoReqProv: no

Modified: trunk/ledgersmb.conf.default
===================================================================
--- trunk/ledgersmb.conf.default	2010-01-22 20:12:54 UTC (rev 2839)
+++ trunk/ledgersmb.conf.default	2010-01-22 20:26:09 UTC (rev 2840)
@@ -4,6 +4,9 @@
 # Set language for login and admin pages
 language : 
 
+# For Windows, uncomment the pathsep line:
+# pathsep : ;
+
 # If you have LaTeX installed, set to 1
 latex : 1
 
@@ -21,6 +24,14 @@
 # logged in at the same time
 cookie_name : LedgerSMB-1.3
 
+# This is the string we look for in the failed connection error to determine
+# if the database was not found.  For English-language locales, this can be
+# left in place.  If the database server is running a different locale, it may
+# need to be changed.  Any partial match on the connection error assumes that
+# the failure to connect was caused by an invalid database request.
+
+no_db_str : database
+
 [environment]
 # If the server can't find applications, append to the path
 PATH: /usr/local/pgsql/bin
@@ -64,3 +75,5 @@
 default_db = lsmb13
 host = localhost
 db_namespace = public
+# sslmode can be require, allow, prefer, or disable.  Defaults to prefer.
+sslmode = prefer

Modified: trunk/scripts/login.pl
===================================================================
--- trunk/scripts/login.pl	2010-01-22 20:12:54 UTC (rev 2839)
+++ trunk/scripts/login.pl	2010-01-22 20:26:09 UTC (rev 2840)
@@ -5,6 +5,7 @@
 use LedgerSMB::Form; # Required for now to integrate with menu module.
 use LedgerSMB::User;
 use LedgerSMB::Auth;
+use LedgerSMB::Sysconfig;
 use strict;
 
 # this is kind of silly, as it doesn't check if someone IS trying to log in.
@@ -62,7 +63,7 @@
         }
     }
     else {
-        if ($request->{_auth_error} =~/database/i){
+        if ($request->{_auth_error} =~/$LedgerSMB::Sysconfig::no_db_str/i){
             print "Status: 454 Database Does Not Exist\n\n";
             print "No message here";
         } else {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.