diff --git a/controllers/ErrorController.inc b/controllers/ErrorController.inc index efdae4f4..a27e3afd 100644 --- a/controllers/ErrorController.inc +++ b/controllers/ErrorController.inc @@ -23,6 +23,8 @@ + + /** * Action: index. * @@ -41,6 +43,7 @@ // Display statuscode and message $this->set('code', $httpStatusCode); $this->set('string', \nre\core\WebUtils::$httpStrings[$httpStatusCode]); + $this->set('userId', $this->Auth->getUserId()); } } diff --git a/controllers/UsersController.inc b/controllers/UsersController.inc index 90e50912..f0888cce 100644 --- a/controllers/UsersController.inc +++ b/controllers/UsersController.inc @@ -117,11 +117,13 @@ public function login() { $username = ''; + $referrer = null; // Log the user in if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('login'))) { $username = $this->request->getPostParam('username'); + $referrer = $this->request->getPostParam('referrer'); $userId = $this->Users->login( $username, $this->request->getPostParam('password') @@ -131,14 +133,20 @@ { $this->Auth->setUserId($userId); $user = $this->Users->getUserById($userId); - - $this->redirect($this->linker->link(array($user['url']), 1)); + + if(!empty($referrer)) { + $this->redirect($referrer); + } + else { + $this->redirect($this->linker->link(array($user['url']), 1)); + } } } // Pass data to view $this->set('username', $username); + $this->set('referrer', $referrer); $this->set('failed', ($this->request->getRequestMethod() == 'POST')); } diff --git a/views/html/error/index.tpl b/views/html/error/index.tpl index 0f68bc07..a0b02462 100644 --- a/views/html/error/index.tpl +++ b/views/html/error/index.tpl @@ -1,2 +1,17 @@
=$code?>: =$string?>
+ + +