Redirect the user if they have already logged in. Fixes #102.

This commit is contained in:
Starbeamrainbowlabs 2016-08-24 19:12:37 +01:00
parent 28f79e5e2d
commit 3ddd63909e
3 changed files with 17 additions and 5 deletions

View File

@ -4243,13 +4243,19 @@ register_module([
* ███████ ██████ ██████ ██ ██ ████
*/
add_action("login", function() {
global $settings;
global $settings, $env;
// Build the action url that will actually perform the login
$login_form_action_url = "index.php?action=checklogin";
if(isset($_GET["returnto"]))
$login_form_action_url .= "&returnto=" . rawurlencode($_GET["returnto"]);
if($env->is_logged_in && !empty($_GET["returnto"]))
{
http_response_code(307);
header("location: " . $_GET["returnto"]);
}
$title = "Login to $settings->sitename";
$content = "<h1>Login to $settings->sitename</h1>\n";
if(isset($_GET["failed"]))

View File

@ -77,7 +77,7 @@
"author": "Starbeamrainbowlabs",
"description": "Adds the ability to upload files to Pepperminty Wiki. Uploaded files act as pages and have the special 'File\/' prefix.",
"id": "feature-upload",
"lastupdate": 1471884248,
"lastupdate": 1471884345,
"optional": false
},
{
@ -149,7 +149,7 @@
"author": "Starbeamrainbowlabs",
"description": "Adds a pair of actions (login and checklogin) that allow users to login. You need this one if you want your users to be able to login.",
"id": "page-login",
"lastupdate": 1466960915,
"lastupdate": 1472061908,
"optional": false
},
{
@ -203,7 +203,7 @@
"author": "Emanuil Rusev & Starbeamrainbowlabs",
"description": "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Please be careful, as this module adds some weight to your installation, and also *requires* write access to the disk on first load.",
"id": "parser-parsedown",
"lastupdate": 1471880277,
"lastupdate": 1471954922,
"optional": false
}
]

View File

@ -26,13 +26,19 @@ register_module([
* ███████ ██████ ██████ ██ ██ ████
*/
add_action("login", function() {
global $settings;
global $settings, $env;
// Build the action url that will actually perform the login
$login_form_action_url = "index.php?action=checklogin";
if(isset($_GET["returnto"]))
$login_form_action_url .= "&returnto=" . rawurlencode($_GET["returnto"]);
if($env->is_logged_in && !empty($_GET["returnto"]))
{
http_response_code(307);
header("location: " . $_GET["returnto"]);
}
$title = "Login to $settings->sitename";
$content = "<h1>Login to $settings->sitename</h1>\n";
if(isset($_GET["failed"]))