Login/logout redirection


 


Here's a small suggestion for the login/logout page.
The idea came while hacking a previous version of wikka to create a content management system with a public, read-only area (with a limited number of visible pages) and a registered-users area giving read&write access to all the pages.
I thought it might be useful to give the site administrator the possibility to automatically redirect logged users to a specific page immediately after the login. Two possible suggestions:

A. Redirect logged users to a specific page
Add a line to wakka.config.php:
"logged_in_homepage" => "IntraNet",
and modify the usersettings.php action so as to redirect logged users to logged_in_homepage:

original:
// check password
        if ($existingUser["password"] == md5($_POST["password"]))
        {
            $this->SetUser($existingUser);
            $this->Redirect($this->href());


modified:
// check password
        if ($existingUser["password"] == md5($_POST["password"]))
        {
            $this->SetUser($existingUser);
            $this->Redirect($this->config["logged_in_homepage"]);


B. Back to original page
Keep track of the referrer from which the user accesses the login page and redirect her to the page she came from.
Any ideas how to implement this?


Same story for the logout screen. For automatic redirecting users to root_page on logout, here's how to modify usersettings.php:

original
<?php
if (isset($_REQUEST["action"]) && ($_REQUEST["action"] == "logout"))
{
    $this->LogoutUser();
    $this->SetMessage("You are now logged out.");
    $this->Redirect($this->href());


modified
<?php
if (isset($_REQUEST["action"]) && ($_REQUEST["action"] == "logout"))
{
    $this->LogoutUser();
    $this->SetMessage("You are now logged out.");

    $this->Redirect($this->config["root_page"]);




Perhaps these options, together with the default one [Stay on login page], might be added in wakka.config.php:
"login_redirect" => "1"
/*
"0" : redirection disabled (stay on UserSettings after login);
"1" : redirect to original page;
"2" : redirect to  logged_in_homepage;
*/


In the same way, the logout redirect behavior could be directly controlled by the wakka_config.php file:
"logout_redirect" => "1"
/*
"0" : redirection disabled (stay on UserSettings after logout);
"1" : redirect to original page;
"2" : redirect to root_page;
*/



CategoryDevelopmentUserAccount
There are 2 comments on this page. [Show comments]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki