From e351961d94e77c882daf86e5726978d0e873eee3 Mon Sep 17 00:00:00 2001
From: hahn <axel.hahn@iml.unibe.ch>
Date: Thu, 11 Jun 2020 14:34:38 +0200
Subject: [PATCH] task#3869 - update sws class

---
 public_html/deployment/classes/user.class.php | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/public_html/deployment/classes/user.class.php b/public_html/deployment/classes/user.class.php
index da03b925..13dc9d68 100644
--- a/public_html/deployment/classes/user.class.php
+++ b/public_html/deployment/classes/user.class.php
@@ -53,15 +53,15 @@ class user {
     
     
     /**
-     * detect a user
-     * @return type
+     * get string with detected user from current session / basic auth / cli access
+     * @return string
      */
     private function _autoDetectUser(){
         $sUser=false;
-        if (isset($_SESSION) && is_array($_SESSION) && array_key_exists("PHP_AUTH_USER", $_SESSION)){
+        if (isset($_SESSION) && isset($_SESSION["PHP_AUTH_USER"])){
             $sUser=$_SESSION["PHP_AUTH_USER"];
         }
-        if (!$sUser && is_array($_SERVER) && array_key_exists("PHP_AUTH_USER", $_SERVER)){
+        if (!$sUser && isset($_SERVER["PHP_AUTH_USER"])){
             $sUser=$_SERVER["PHP_AUTH_USER"];
         }
         if (php_sapi_name() == "cli") {
@@ -137,7 +137,7 @@ class user {
      */
     public function authenticate(){
         global $aConfig, $aParams;
-        
+        print_r($aConfig);
         if(!array_key_exists('auth', $aConfig) || !count($aConfig['auth']) || !array_key_exists('user', $aParams)){
             return false;
         }
@@ -180,10 +180,11 @@ class user {
     }
     
     /**
-     * set a authenticated user and get its roles
+     * set an authenticated user and get its roles
      */
     public function setUser(){
         $this->_sUsername=$this->_autoDetectUser();
+        
         $this->_getUserGroups();
         $this->_getUserPermission();
     }
-- 
GitLab