diff --git a/controllers/authentication.php b/controllers/authentication.php index 5b663e0..fc31245 100644 --- a/controllers/authentication.php +++ b/controllers/authentication.php @@ -26,9 +26,19 @@ public function get_logout(array $args) public function get_login(array $args) { + if (!isset($this->data['redirect_url'])) + { + $this->data['redirect_url'] = '/'; + + if (isset($_GET['redirect'])) + { + $this->data['redirect_url'] = $_GET['redirect']; + } + } + if (midgardmvc_core::get_instance()->authentication->is_user()) { - midgardmvc_core::get_instance()->head->relocate('/'); + midgardmvc_core::get_instance()->head->relocate($this->data['redirect_url']); } $exception_data = array(); @@ -41,6 +51,11 @@ public function get_login(array $args) public function post_login(array $args) { + if (isset($_POST['redirect'])) + { + $this->data['redirect_url'] = $_POST['redirect']; + } + if ( isset($_POST['username']) && isset($_POST['password'])) { diff --git a/templates/midgardmvc-login-form.xhtml b/templates/midgardmvc-login-form.xhtml index 77f2d77..327d020 100644 --- a/templates/midgardmvc-login-form.xhtml +++ b/templates/midgardmvc-login-form.xhtml @@ -19,6 +19,7 @@
Lorem ipsum
+