diff options
author | Andrew Dolgov <[email protected]> | 2021-12-06 13:20:18 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2021-12-06 13:20:18 +0300 |
commit | 53061d150814cf5939d1d4dc165d8270ca764109 (patch) | |
tree | 5fd1b2c095dd54291d45cc9cb48037f021165c44 /classes/handler/public.php | |
parent | 57b0413a3a8b8f73276382d51cf560c09ac6fbc6 (diff) |
* add HOOK_POST_LOGOUT
* auth_remote: add config option AUTH_REMOTE_POST_LOGOUT_URL
Diffstat (limited to 'classes/handler/public.php')
-rwxr-xr-x | classes/handler/public.php | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/classes/handler/public.php b/classes/handler/public.php index d0776f03c..3fef4c2b9 100755 --- a/classes/handler/public.php +++ b/classes/handler/public.php @@ -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); |