Bug 18570: (QA follow-up) Improved POD
[koha.git] / C4 / InstallAuth.pm
index c91bde8..9d285bd 100644 (file)
@@ -20,6 +20,7 @@ package C4::InstallAuth;
 use strict;
 #use warnings; FIXME - Bug 2505
 use Digest::MD5 qw(md5_base64);
+use File::Spec;
 
 require Exporter;
 use C4::Context;
@@ -148,6 +149,10 @@ sub get_template_and_user {
             $template->param( CAN_user_serials          => 1 );
             $template->param( CAN_user_reports          => 1 );
         }
+
+        my $minPasswordLength = C4::Context->preference('minPasswordLength');
+        $minPasswordLength = 3 if not $minPasswordLength or $minPasswordLength < 3;
+        $template->param(minPasswordLength => $minPasswordLength,);
     }
     return ( $template, $borrowernumber, $cookie );
 }
@@ -233,6 +238,7 @@ sub checkauth {
     my $dbh = C4::Context->dbh();
     my $template_name;
     $template_name = "installer/auth.tt";
+    my $sessdir = File::Spec->catdir( File::Spec->tmpdir, 'cgisess_' . C4::Context->config('database') ); # same construction as in C4/Auth
 
     # state variables
     my $loggedin = 0;
@@ -243,7 +249,7 @@ sub checkauth {
         C4::Context->_new_userenv($sessionID);
         my $session =
           new CGI::Session( "driver:File;serializer:yaml", $sessionID,
-            { Directory => '/tmp' } );
+            { Directory => $sessdir } );
         if ( $session->param('cardnumber') ) {
             C4::Context->set_userenv(
                 $session->param('number'),
@@ -283,7 +289,7 @@ sub checkauth {
     }
     unless ($userid) {
         my $session =
-          new CGI::Session( "driver:File;serializer:yaml", undef, { Directory => '/tmp' } );
+          new CGI::Session( "driver:File;serializer:yaml", undef, { Directory => $sessdir } );
         $sessionID = $session->id;
         $userid    = $query->param('userid');
         C4::Context->_new_userenv($sessionID);
@@ -379,6 +385,10 @@ sub checkauth {
     $template->param( login => 1 );
     $template->param( loginprompt => 1 ) unless $info{'nopermission'};
 
+    if ($info{'invalid_username_or_password'} == 1) {
+                $template->param( 'invalid_username_or_password' => $info{'invalid_username_or_password'});
+    }
+
     $template->param( \%info );
     $cookie = $query->cookie(
         -name    => 'CGISESSID',
@@ -413,16 +423,6 @@ sub checkpw {
         );
         return 2;
     }
-    if (   $userid
-        && $userid     eq 'demo'
-        && "$password" eq 'demo'
-        && C4::Context->config('demo') )
-    {
-
-# DEMO => the demo user is allowed to do everything (if demo set to 1 in koha.conf
-# some features won't be effective : modify systempref, modify MARC structure,
-        return 2;
-    }
     return 0;
 }