From d70013544c615f15c9ea2c90b8c07c0b8ae8af15 Mon Sep 17 00:00:00 2001
From: Mark Tompsett <mtompset@hotmail.com>
Date: Thu, 28 Nov 2013 13:23:11 -0500
Subject: [PATCH] Bug 11077 - Fix indents to trace code more easily

---
 C4/Auth.pm |   40 ++++++++++++++++++++++------------------
 1 file changed, 22 insertions(+), 18 deletions(-)

diff --git a/C4/Auth.pm b/C4/Auth.pm
index 790f56c..ab52ea0 100644
--- a/C4/Auth.pm
+++ b/C4/Auth.pm
@@ -763,7 +763,11 @@ sub checkauth {
             -HttpOnly => 1
         );
         $userid = $q_userid;
-        my $pki_field = C4::Context->preference('AllowPKIAuth') // '';
+        my $pki_field = C4::Context->preference('AllowPKIAuth');
+        if (!defined($pki_field)) {
+            print STDERR "Error: Missing AllowPKIAuth System Preference!\n";
+            $pki_field = '';
+        }
         if (   ( $cas && $query->param('ticket') )
             || $userid
             || $pki_field ne 'None'
@@ -780,28 +784,28 @@ sub checkauth {
                 $info{'invalidCasLogin'} = 1 unless ($return);
             }
 
-    elsif ($persona) {
-        my $value = $persona;
+            elsif ($persona) {
+                my $value = $persona;
 
         # If we're looking up the email, there's a chance that the person
         # doesn't have a userid. So if there is none, we pass along the
         # borrower number, and the bits of code that need to know the user
         # ID will have to be smart enough to handle that.
-        require C4::Members;
-        my @users_info = C4::Members::GetBorrowersWithEmail($value);
-        if (@users_info) {
+                require C4::Members;
+                my @users_info = C4::Members::GetBorrowersWithEmail($value);
+                if (@users_info) {
 
             # First the userid, then the borrowernum
-            $value = $users_info[0][1] || $users_info[0][0];
-        }
-        else {
-            undef $value;
-        }
-        $return = $value ? 1 : 0;
-        $userid = $value;
-    }
+                    $value = $users_info[0][1] || $users_info[0][0];
+                }
+                else {
+                    undef $value;
+                }
+                $return = $value ? 1 : 0;
+                $userid = $value;
+            }
 
-    elsif (
+            elsif (
                 ( $pki_field eq 'Common Name' && $ENV{'SSL_CLIENT_S_DN_CN'} )
                 || (   $pki_field eq 'emailAddress'
                     && $ENV{'SSL_CLIENT_S_DN_Email'} )
@@ -833,14 +837,14 @@ sub checkauth {
                 $return = $value ? 1 : 0;
                 $userid = $value;
 
-    }
+            }
             else {
                 my $retuserid;
                 ( $return, $cardnumber, $retuserid ) =
                   checkpw( $dbh, $userid, $password, $query );
                 $userid = $retuserid if ( $retuserid );
-        }
-        if ($return) {
+            }
+            if ($return) {
                #_session_log(sprintf "%20s from %16s logged in  at %30s.\n", $userid,$ENV{'REMOTE_ADDR'},(strftime '%c', localtime));
                 if ( $flags = haspermission(  $userid, $flagsrequired ) ) {
                     $loggedin = 1;
-- 
1.7.9.5