From 398ebe816f979a6418535c60c651304731b9dcd8 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Wed, 6 Aug 2014 15:20:50 -0400
Subject: [PATCH] Cleaned up logic related to IP authentication.

---
 .../src/VuFindSearch/Backend/EDS/Backend.php  | 29 ++++++-------------
 1 file changed, 9 insertions(+), 20 deletions(-)

diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Backend.php b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Backend.php
index 326cea51a37..1ba3e515ca4 100644
--- a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Backend.php
+++ b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Backend.php
@@ -404,7 +404,7 @@ class Backend extends AbstractBackend
     protected function getAuthenticationToken($isInvalid = false)
     {
         $token = null;
-        if (!empty($this->ipAuth) && true == $this->ipAuth) {
+        if ($this->ipAuth) {
             return $token;
         }
         if ($isInvalid) {
@@ -496,16 +496,9 @@ class Backend extends AbstractBackend
      */
     protected function createEBSCOSession()
     {
-        // If the user is not logged in, the treat them as a guest. Unless they are
-        // using IP Authentication.
-        // If IP Authentication is used, then don't treat them as a guest.
-        $guest = ($this->isAuthenticationIP()) ? 'n' : $this->isGuest();
-
+        $guest = $this->isGuest();
         // if there is no profile passed, restore the default from the config file
-        $profile = $this->profile;
-        if (null == $profile) {
-            $profile = $this->defaultProfile;
-        }
+        $profile = (null == $this->profile) ? $this->defaultProfile : $this->profile;
         $session = $this->createSession($guest, $profile);
         $this->session->sessionID = $session;
         $this->session->profileID = $profile;
@@ -521,22 +514,18 @@ class Backend extends AbstractBackend
      */
     protected function isGuest()
     {
+        // If the user is not logged in, then treat them as a guest. Unless they are
+        // using IP Authentication.
+        // If IP Authentication is used, then don't treat them as a guest.
+        if ($this->ipAuth) {
+            return 'n';
+        }
         if (isset($this->authManager)) {
             return $this->authManager->isLoggedIn() ? 'n' : 'y';
         }
         return 'y';
     }
 
-     /**
-     * Is IP Authentication being used?
-     *
-     * @return bool
-     */
-    protected function isAuthenticationIP()
-    {
-        return 'true' == $this->ipAuth;
-    }
-
     /**
      * Obtain the session to use with the EDS API from cache if it exists. If not,
      * then generate a new one.
-- 
GitLab