Skip to content
Permalink
Browse files

Setting up user auto-login

  • Loading branch information...
turnermm committed Mar 13, 2019
1 parent e8f6f65 commit 3596593bb227ebd31dba22304ccaf5ef00e89b5e
Showing with 27 additions and 5 deletions.
  1. +11 −3 action.php
  2. +11 −0 script.js
  3. +5 −2 syntax.php
@@ -4,12 +4,20 @@
require_once(DOKU_PLUGIN.'action.php');
class action_plugin_goto extends DokuWiki_Action_Plugin {
public function register(Doku_Event_Handler $controller) {
$controller->register_hook('AUTH_LOGIN_CHECK', 'BEFORE', $this, 'handle_login',array('before'));
$controller->register_hook('AUTH_LOGIN_CHECK', 'BEFORE', $this, 'handle_login',array('before'));
}
function handle_login(Doku_Event $event, $param) {
global $conf;
$auto_login = 0;
if(!empty($event->data['user'])) {
$value = $event->data['user'];
setcookie("DOKU_GOTO", $value, time()+120, DOKU_BASE);
if($auto_login) {
$value = ':' . $event->data['user'] . ':' . $conf['start'] ;
setcookie("GOTO_LOGIN", $value, time()+120, DOKU_BASE);
return;
}
else {
setcookie("DOKU_GOTO", $event->data['user'], time()+120, DOKU_BASE);
}
}
}
}
@@ -21,3 +21,14 @@ function setGotoCookie(cname, cvalue) {
var expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path="+DOKU_BASE;
}

jQuery( document ).ready(function() {

var which = goto_getCookie("GOTO_LOGIN");

if(!which) {
return;
}
location.href = DOKU_BASE + 'doku.php?id=' + decodeURIComponent(which) ;
setGotoCookie("GOTO_LOGIN", "") ;
});
@@ -38,6 +38,7 @@ function handle($match, $state, $pos, Doku_Handler $handler){
if($matches[0] == 'user') {
$matches[0] = ": $userid";
$is_usr = true;
$seconds = 1;
}
if (is_numeric($matches[1])){ $seconds = $matches[1]; }
if ($seconds < $minSeconds){ $seconds = $minSeconds; }//Check that seconds is greater than $minSeconds.
@@ -62,8 +63,10 @@ function render($mode, Doku_Renderer $renderer, $data) {
if(!$data[3]) {
$renderer->doc .= '<script>url="'.$url.'";setTimeout("location.href=url",'.($data[1]*1000).');</script>';
}
$tm =($data[1]*1000);
$renderer->doc .= "<script>var goto_tm= setTimeout(function(){goto_redirect('$url');},$tm);</script>";
else{
$tm =($data[1]*1000);
$renderer->doc .= "<script>var goto_tm= setTimeout(function(){goto_redirect('$url');},$tm);</script>";
}
}
}

0 comments on commit 3596593

Please sign in to comment.
You can’t perform that action at this time.