Module: nagvis
Branch: master
Commit: 5a8185099fcb59d28c0cda19bf1212ba7c6b6523
URL:    
http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=5a8185099fcb59d28c0cda19bf1212ba7c6b6523

Author: LaMi <[email protected]>
Date:   Tue Mar  9 19:38:03 2010 +0100

#209 Only showing logout link when not authed with trusted auth

---

 .../nagvis-js/classes/NagVisHeaderMenu.php         |    6 ++++--
 share/server/core/classes/CoreAuthHandler.php      |   18 +++++++++++++-----
 share/server/core/classes/CoreModAuth.php          |    8 +++++---
 3 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/share/frontend/nagvis-js/classes/NagVisHeaderMenu.php 
b/share/frontend/nagvis-js/classes/NagVisHeaderMenu.php
index 4300ab9..1ed0a41 100644
--- a/share/frontend/nagvis-js/classes/NagVisHeaderMenu.php
+++ b/share/frontend/nagvis-js/classes/NagVisHeaderMenu.php
@@ -116,8 +116,10 @@ class NagVisHeaderMenu {
                
                $this->aMacros['currentUser'] = 
$this->AUTHORISATION->getAuthentication()->getUser();
                
-               $this->aMacros['permittedChangePassword'] = 
$this->CORE->getAuthorization()->isPermitted('ChangePassword', 'change', '*');
-               $this->aMacros['permittedLogout'] = 
$this->CORE->getAuthorization()->isPermitted('Auth', 'logout', '*');
+               $this->aMacros['permittedChangePassword'] = 
$this->AUTHORISATION->isPermitted('ChangePassword', 'change', '*');
+               
+               $this->aMacros['permittedLogout'] = 
$this->AUTHORISATION->getAuthentication()->logoutSupported()
+                                        & 
$this->AUTHORISATION->isPermitted('Auth', 'logout', '*');
                
                // Replace some special macros
                if($this->OBJ !== null && ($this->aMacros['mod'] == 'Map' || 
$this->aMacros['mod'] == 'AutoMap')) {
diff --git a/share/server/core/classes/CoreAuthHandler.php 
b/share/server/core/classes/CoreAuthHandler.php
index 6fec939..3bbbe1e 100644
--- a/share/server/core/classes/CoreAuthHandler.php
+++ b/share/server/core/classes/CoreAuthHandler.php
@@ -165,13 +165,21 @@ class CoreAuthHandler {
                                
                return $this->bIsAuthenticated;
        }
+
+       public function logoutSupported() {
+               return ! $this->SESS->isSetAndNotEmpty('authTrusted');
+       }
        
        public function logout() {
-               // Remove the login information
-               $this->SESS->set('authCredentials', false);
-               $this->SESS->set('userPermissions', false);
-               
-               return true;
+               if($this->logoutSupported()) {
+                       // Remove the login information
+                       $this->SESS->set('authCredentials', false);
+                       $this->SESS->set('userPermissions', false);
+                       
+                       return true;
+               } else {
+                       return false;
+               }
        }
 }
 ?>
diff --git a/share/server/core/classes/CoreModAuth.php 
b/share/server/core/classes/CoreModAuth.php
index 7b19be0..ea28945 100644
--- a/share/server/core/classes/CoreModAuth.php
+++ b/share/server/core/classes/CoreModAuth.php
@@ -49,9 +49,11 @@ class CoreModAuth extends CoreModule {
                                        }
                                break;
                                case 'logout':
-                                       $this->AUTHENTICATION->logout();
-                                       
-                                       new GlobalMessage('NOTE', 
$this->CORE->getLang()->getText('You have been logged out. You will be 
redirected.'), null, null, 1, $this->CORE->getMainCfg()->getValue('paths', 
'htmlbase'));
+                                       if($this->AUTHENTICATION->logout()) {
+                                               new GlobalMessage('NOTE', 
$this->CORE->getLang()->getText('You have been logged out. You will be 
redirected.'), null, null, 1, $this->CORE->getMainCfg()->getValue('paths', 
'htmlbase'));
+                                       } else {
+                                               new GlobalMessage('ERROR', 
$this->CORE->getLang()->getText('Unable to log you out. Maybe it is not 
supported by your authentication module.'), null, null, 1, 
$this->CORE->getMainCfg()->getValue('paths', 'htmlbase'));
+                                       }
                                break;
                        }
                }


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to