forked from StartupAPI/users
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logout.php
52 lines (43 loc) · 1.49 KB
/
logout.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
require_once(__DIR__.'/global.php');
require_once(__DIR__.'/classes/User.php');
UserConfig::$IGNORE_REQUIRED_EMAIL_VERIFICATION = true;
// first, we need to auto-logout all modules that require that
$autologgedout_module_reached = false;
$module_logout_url = null;
foreach (UserConfig::$authentication_modules as $module) {
if (array_key_exists('autologgedout', $_GET)) {
// skip modules that were already autologged out
if (!$autologgedout_module_reached && $module->getID() == $_GET['autologgedout']) {
$autologgedout_module_reached = true;
continue;
}
if ($autologgedout_module_reached) {
$module_logout_url = $module->getAutoLogoutURL(UserConfig::$USERSROOTFULLURL.'/logout.php?autologgedout='.urlencode($module->getID()));
}
} else {
// if we didn't auto-logout any modules yet, do it for first module
$module_logout_url = $module->getAutoLogoutURL(UserConfig::$USERSROOTFULLURL.'/logout.php?autologgedout='.urlencode($module->getID()));
}
// if we reached a module that needs auto-logout, redirect there
if (!is_null($module_logout_url)) {
header('Location: '.$module_logout_url);
exit;
}
}
// if we're here, it means there were no auto-logout modules or all auto-logouts are complete
User::clearSession();
$user = User::get();
if (!is_null($user)) {
$user->recordActivity(USERBASE_ACTIVITY_LOGOUT);
}
$return = User::getReturn();
User::clearReturn();
if (!is_null($return))
{
header('Location: '.$return);
}
else
{
header('Location: '.UserConfig::$DEFAULTLOGOUTRETURN);
}