Skip to content

Commit

Permalink
Redirect the user if they have already logged in. Fixes #102.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrl committed Aug 24, 2016
1 parent 28f79e5 commit 3ddd639
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
8 changes: 7 additions & 1 deletion build/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4243,13 +4243,19 @@ function generate_page_list($pagelist)
* ███████ ██████ ██████ ██ ██ ████
*/
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"]))
Expand Down
6 changes: 3 additions & 3 deletions module_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
{
Expand Down Expand Up @@ -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
},
{
Expand Down Expand Up @@ -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
}
]
8 changes: 7 additions & 1 deletion modules/page-login.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,19 @@
* ███████ ██████ ██████ ██ ██ ████
*/
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"]))
Expand Down

0 comments on commit 3ddd639

Please sign in to comment.