1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-13 13:45:56 +00:00

* add HOOK_POST_LOGOUT

* auth_remote: add config option AUTH_REMOTE_POST_LOGOUT_URL
This commit is contained in:
Andrew Dolgov
2021-12-06 13:20:18 +03:00
parent 57b0413a3a
commit 53061d1508
4 changed files with 48 additions and 2 deletions

View File

@@ -296,8 +296,25 @@ class Handler_Public extends Handler {
function logout(): void {
if (validate_csrf($_POST["csrf_token"])) {
$login = $_SESSION["name"];
$user_id = $_SESSION["uid"];
UserHelper::logout();
header("Location: index.php");
$redirect_url = "";
PluginHost::getInstance()->run_hooks_callback(PluginHost::HOOK_POST_LOGOUT,
function ($result) use (&$redirect_url) {
if (!empty($result[0]))
$redirect_url = UrlHelper::validate($result[0]);
},
$login, $user_id);
if (!$redirect_url)
$redirect_url = get_self_url_prefix() . "/index.php";
header("Location: " . $redirect_url);
} else {
header("Content-Type: text/json");
print Errors::to_json(Errors::E_UNAUTHORIZED);

View File

@@ -670,4 +670,13 @@ abstract class Plugin {
return false;
}
/** Invoked after user logout, may override built-in behavior (redirect back to login page)
* @param string $login
* @param int $user_id
* @return array<mixed> - [0] - if set, url to redirect to
*/
function hook_post_logout($login, $user_id) {
return [""];
}
}

View File

@@ -195,6 +195,9 @@ class PluginHost {
/** @see Plugin::hook_pre_subscribe() */
const HOOK_PRE_SUBSCRIBE = "hook_pre_subscribe";
/** @see Plugin::hook_post_logout() */
const HOOK_POST_LOGOUT = "hook_post_logout";
const KIND_ALL = 1;
const KIND_SYSTEM = 2;
const KIND_USER = 3;