Skip to content

Commit

Permalink
Implement redirection support for logins
Browse files Browse the repository at this point in the history
  • Loading branch information
bergie committed Feb 3, 2011
1 parent 3dc6804 commit 0c3192d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
17 changes: 16 additions & 1 deletion controllers/authentication.php
Expand Up @@ -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();
Expand All @@ -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']))
{
Expand Down
1 change: 1 addition & 0 deletions templates/midgardmvc-login-form.xhtml
Expand Up @@ -19,6 +19,7 @@
<div class="errors" tal:content="midgardmvc_core_exceptionhandler/message">Lorem ipsum</div>

<form method='post' action=''>
<input type="hidden" name="redirect" tal:attributes="value current_component/redirect_url" />
<table>
<tr>
<td>
Expand Down

0 comments on commit 0c3192d

Please sign in to comment.