Skip to content

Commit

Permalink
Stop trying to parse the continue url in the logout controller because
Browse files Browse the repository at this point in the history
it requires us to reproduce a bunch of complex routing logic.
Instead, just have the logout link generating code generate a link
that's visible to guests.
  • Loading branch information
bharat committed Jun 12, 2010
1 parent a4586bc commit 63d9508
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
12 changes: 2 additions & 10 deletions modules/gallery/controllers/logout.php
Expand Up @@ -22,16 +22,8 @@ public function index() {
access::verify_csrf();
auth::logout();
if ($continue_url = Input::instance()->get("continue")) {
$components = explode("/", parse_url($continue_url, PHP_URL_PATH), 4);
$item = url::get_item_from_uri($components[3]);
if (access::can("view", $item)) {
// Don't use url::redirect() because it'll call url::site() and munge the continue url.
header("Location: {$item->relative_url()}");
} else {
url::redirect(item::root()->abs_url());
}
} else {
url::redirect(item::root()->abs_url());
url::redirect($continue_url);
}
url::redirect(item::root()->abs_url());
}
}
13 changes: 12 additions & 1 deletion modules/gallery/helpers/gallery_event.php
Expand Up @@ -157,11 +157,22 @@ static function user_menu($menu, $theme) {
->view("login_current_user.html")
->url(user_profile::url($user->id))
->label($user->display_name()));

if (isset($theme->item)) {
if (access::user_can(identity::guest(), "view", $theme->item)) {
$continue_url = $theme->item->abs_url();
} else {
$continue_url = item::root()->abs_url();
}
} else {
$continue_url = url::abs_current();
}

$menu->append(Menu::factory("link")
->id("user_menu_logout")
->css_id("g-logout-link")
->url(url::site("logout?csrf=$csrf&continue=" .
urlencode(url::abs_current())))
urlencode($continue_url)))
->label(t("Logout")));
}
}
Expand Down

0 comments on commit 63d9508

Please sign in to comment.