Commit edab4656135b05767c0251a238e5c21c27c2e122
1 parent
9357e454
Redirect to the login page if nobody is logged on or if a session has
expired and so forth. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3897 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
16 additions
and
2 deletions
lib/dispatcher.inc.php
| @@ -108,20 +108,34 @@ class KTStandardDispatcher extends KTDispatcher { | @@ -108,20 +108,34 @@ class KTStandardDispatcher extends KTDispatcher { | ||
| 108 | 108 | ||
| 109 | function permissionDenied () { | 109 | function permissionDenied () { |
| 110 | print "Permission denied"; | 110 | print "Permission denied"; |
| 111 | + exit(0); | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + function loginRequired() { | ||
| 115 | + $url = generateControllerUrl("loginForm"); | ||
| 116 | + $redirect = urlencode($_SERVER['REQUEST_URI']); | ||
| 117 | + if ((strlen($redirect) > 1)) { | ||
| 118 | + $url = $url . "&redirect=" . $redirect; | ||
| 119 | + } | ||
| 120 | + redirect($url); | ||
| 121 | + exit(0); | ||
| 111 | } | 122 | } |
| 112 | 123 | ||
| 113 | function dispatch () { | 124 | function dispatch () { |
| 114 | $session = new Session(); | 125 | $session = new Session(); |
| 115 | $sessionStatus = $session->verify($bDownload); | 126 | $sessionStatus = $session->verify($bDownload); |
| 127 | + if ($sessionStatus === false) { | ||
| 128 | + $this->loginRequired(); | ||
| 129 | + } | ||
| 116 | 130 | ||
| 117 | if ($bLogonRequired !== false) { | 131 | if ($bLogonRequired !== false) { |
| 118 | if (empty($_SESSION['userID'])) { | 132 | if (empty($_SESSION['userID'])) { |
| 119 | - $this->permissionDenied(); | 133 | + $this->loginRequired(); |
| 120 | exit(0); | 134 | exit(0); |
| 121 | } | 135 | } |
| 122 | $this->oUser =& User::get($_SESSION['userID']); | 136 | $this->oUser =& User::get($_SESSION['userID']); |
| 123 | if (PEAR::isError($this->oUser) || ($this->oUser === false)) { | 137 | if (PEAR::isError($this->oUser) || ($this->oUser === false)) { |
| 124 | - $this->permissionDenied(); | 138 | + $this->loginRequired(); |
| 125 | exit(0); | 139 | exit(0); |
| 126 | } | 140 | } |
| 127 | } | 141 | } |