Refactor logoutpage_hook function
This commit is contained in:
parent
01949baf71
commit
bf41c01c12
1 changed files with 25 additions and 2 deletions
27
auth.php
27
auth.php
|
@ -384,6 +384,29 @@ class auth_plugin_userkey extends auth_plugin_base {
|
||||||
return $parameters;
|
return $parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if we should redirect a user after logout.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function should_redirect() {
|
||||||
|
global $SESSION;
|
||||||
|
|
||||||
|
if (!isset($SESSION->userkey)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($this->config->redirecturl)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($this->config->redirecturl)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logout page hook.
|
* Logout page hook.
|
||||||
*
|
*
|
||||||
|
@ -392,9 +415,9 @@ class auth_plugin_userkey extends auth_plugin_base {
|
||||||
* @see auth_plugin_base::logoutpage_hook()
|
* @see auth_plugin_base::logoutpage_hook()
|
||||||
*/
|
*/
|
||||||
public function logoutpage_hook() {
|
public function logoutpage_hook() {
|
||||||
global $redirect, $SESSION;
|
global $redirect;
|
||||||
|
|
||||||
if (!empty($this->config->redirecturl) && isset($SESSION->userkey)) {
|
if ($this->should_redirect()) {
|
||||||
$redirect = $this->config->redirecturl;
|
$redirect = $this->config->redirecturl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue