Revision history for RedirectOnLogin


Revision [19216]

Last edited on 2008-01-28 00:14:43 by DaC [Modified links pointing to docs server]

No Differences

Revision [16995]

Edited on 2007-05-31 23:27:33 by DaC [Reverted]
Additions:
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##: %%(php)"logged_in_homepage" => "IntraNet",%% and modify the ##usersettings.php## action so as to redirect logged users to ##logged_in_homepage##:
**original**:
%%(php)// check password
if ($existingUser["password"] == md5($_POST["password"]))
{
$this->SetUser($existingUser);
$this->Redirect($this->href());%%
~& It should be noted that the original function now (v1.1.6.2) looks a little different. This also applies to the Logout part. Althought it's not very difficult to figure this out, but if somebody is trying to do a copy&paste mod (like in phpBB) he could get confused. Therefore I thought it is worth noting. --DaC
~& %%php// check password
switch(TRUE){
case (strlen($_POST['password']) == 0):
$error = ERROR_EMPTY_PASSWORD;
$password_highlight = INPUT_ERROR_STYLE;
break;
case (md5($_POST['password']) != $existingUser['password']):
$error = ERROR_WRONG_PASSWORD;
$password_highlight = INPUT_ERROR_STYLE;
break;
default:
$this->SetUser($existingUser);
$this->Redirect($url, '');
}%%
**modified**:
%%(php)// 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?
~&Since referrer isn't reliable (with browsers or privacy software possibly preventing this from being sent back to the server), the best approach is probably to dynamically add a URL parameter to the Login link (for instance ##&from=[ThisPage]##); the Login action can then pick up this parameter (after proper vetting that it's an existing page) an dredirect back to it. --JavaWoman
----
Same story for the **logout screen**. For automatic redirecting users to ##root_page## on logout, here's how to modify ##usersettings.php##:
**original**
%%(php)<?php
if (isset($_REQUEST["action"]) && ($_REQUEST["action"] == "logout"))
{
$this->LogoutUser();
$this->SetMessage("You are now logged out.");
$this->Redirect($this->href());
%%
~& Original code looks different in v1.1.6.2. --DaC
~&
~&%%(php)if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'logout'))
{
$this->LogoutUser();
$params .= 'out=true';
$this->Redirect($url.$params);
}%%
**modified**
%%(php)<?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##: %%(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:
%%(php)"logout_redirect" => "1"
/*
"0" : redirection disabled (stay on UserSettings after logout);
"1" : redirect to original page;
"2" : redirect to root_page;
*/%%
----
CategoryDevelopmentUserAccount
Deletions:
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


Revision [16794]

Edited on 2007-05-31 10:48:45 by En6P6l [Reverted]
Additions:
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
Deletions:
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##: %%(php)"logged_in_homepage" => "IntraNet",%% and modify the ##usersettings.php## action so as to redirect logged users to ##logged_in_homepage##:
**original**:
%%(php)// check password
if ($existingUser["password"] == md5($_POST["password"]))
{
$this->SetUser($existingUser);
$this->Redirect($this->href());%%
~& It should be noted that the original function now (v1.1.6.2) looks a little different. This also applies to the Logout part. Althought it's not very difficult to figure this out, but if somebody is trying to do a copy&paste mod (like in phpBB) he could get confused. Therefore I thought it is worth noting. --DaC
~& %%php// check password
switch(TRUE){
case (strlen($_POST['password']) == 0):
$error = ERROR_EMPTY_PASSWORD;
$password_highlight = INPUT_ERROR_STYLE;
break;
case (md5($_POST['password']) != $existingUser['password']):
$error = ERROR_WRONG_PASSWORD;
$password_highlight = INPUT_ERROR_STYLE;
break;
default:
$this->SetUser($existingUser);
$this->Redirect($url, '');
}%%
**modified**:
%%(php)// 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?
~&Since referrer isn't reliable (with browsers or privacy software possibly preventing this from being sent back to the server), the best approach is probably to dynamically add a URL parameter to the Login link (for instance ##&from=[ThisPage]##); the Login action can then pick up this parameter (after proper vetting that it's an existing page) an dredirect back to it. --JavaWoman
----
Same story for the **logout screen**. For automatic redirecting users to ##root_page## on logout, here's how to modify ##usersettings.php##:
**original**
%%(php)<?php
if (isset($_REQUEST["action"]) && ($_REQUEST["action"] == "logout"))
{
$this->LogoutUser();
$this->SetMessage("You are now logged out.");
$this->Redirect($this->href());
%%
~& Original code looks different in v1.1.6.2. --DaC
~&
~&%%(php)if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'logout'))
{
$this->LogoutUser();
$params .= 'out=true';
$this->Redirect($url.$params);
}%%
**modified**
%%(php)<?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##: %%(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:
%%(php)"logout_redirect" => "1"
/*
"0" : redirection disabled (stay on UserSettings after logout);
"1" : redirect to original page;
"2" : redirect to root_page;
*/%%
----
CategoryDevelopmentUserAccount


Revision [15864]

Edited on 2007-01-09 07:32:26 by DaC [Reverted]
Additions:
~& It should be noted that the original function now (v1.1.6.2) looks a little different. This also applies to the Logout part. Althought it's not very difficult to figure this out, but if somebody is trying to do a copy&paste mod (like in phpBB) he could get confused. Therefore I thought it is worth noting. --DaC
~& %%php// check password
switch(TRUE){
case (strlen($_POST['password']) == 0):
$error = ERROR_EMPTY_PASSWORD;
$password_highlight = INPUT_ERROR_STYLE;
break;
case (md5($_POST['password']) != $existingUser['password']):
$error = ERROR_WRONG_PASSWORD;
$password_highlight = INPUT_ERROR_STYLE;
break;
default:
$this->SetUser($existingUser);
$this->Redirect($url, '');
}%%
Same story for the **logout screen**. For automatic redirecting users to ##root_page## on logout, here's how to modify ##usersettings.php##:
~& Original code looks different in v1.1.6.2. --DaC
~&
~&%%(php)if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'logout'))
$params .= 'out=true';
$this->Redirect($url.$params);
}%%
Deletions:
Same story for the **logout screen**. For automatic redirectng users to ##root_page## on logout, here's how to modify ##usersettings.php##:


Revision [9808]

Edited on 2005-07-05 16:00:36 by DarTar [adding seealso box and category]
Deletions:
Does this interest anyone?
-- DarTar


Revision [9807]

Edited on 2005-07-05 15:59:58 by DarTar [adding seealso box and category]
Additions:
=====Login/logout redirection=====
>>**See also:** UserAccountModules>>::c::
CategoryDevelopmentUserAccount
Deletions:
===Login/logout redirection===


Revision [9752]

Edited on 2005-07-04 09:10:09 by JavaWoman [adding note for "back to original page" (+ layout)]
Additions:
==A. Redirect logged users to a specific page==
==B. Back to original page==
~&Since referrer isn't reliable (with browsers or privacy software possibly preventing this from being sent back to the server), the best approach is probably to dynamically add a URL parameter to the Login link (for instance ##&from=[ThisPage]##); the Login action can then pick up this parameter (after proper vetting that it's an existing page) an dredirect back to it. --JavaWoman
In the same way, the logout redirect behavior could be directly controlled by the ##wakka_config.php## file:
Deletions:
**A. Redirect logged users to a specific page**
**B. Back to original page**
In the same way, the logout redirect behavior could be directly controlled by the ##wakka_config.php## file


Revision [807]

The oldest known version of this page was created on 2004-07-29 14:59:59 by DarTar [adding note for "back to original page" (+ layout)]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki