mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
For captive portal, if a user reloads index.php of the portal while already logged in, show the logout page instead if it's custom.
Must be a custom logout page that does not include a redirect.
This commit is contained in:
parent
5240564c05
commit
d2ecbddc79
@ -2406,4 +2406,15 @@ function captiveportal_send_server_accounting($off = false) {
|
||||
$racct->close();
|
||||
return $retvalue;
|
||||
}
|
||||
|
||||
function captiveportal_isip_logged($clientip) {
|
||||
global $g, $cpzone;
|
||||
|
||||
/* read in client database */
|
||||
$query = "WHERE ip = '{$clientip}'";
|
||||
$cpdb = captiveportal_read_db($query);
|
||||
foreach ($cpdb as $cpentry) {
|
||||
return $cpentry;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -71,8 +71,25 @@ if (!$clientip) {
|
||||
return;
|
||||
}
|
||||
|
||||
$cpsession = captiveportal_isip_logged($clientip);
|
||||
$ourhostname = portal_hostname_from_client_ip($clientip);
|
||||
if ($orig_host != $ourhostname) {
|
||||
/* Automatically switching to the logout page requires a custom logout page to be present. */
|
||||
if ((!empty($cpsession)) && (! $_POST['logout_id']) && (!empty($cpcfg['page']['logouttext']))) {
|
||||
/* if client already logged in so show logout page */
|
||||
$protocol = (isset($config['captiveportal'][$cpzone]['httpslogin'])) ? 'https://' : 'http://';
|
||||
$logouturl = "{$protocol}{$ourhostname}/";
|
||||
|
||||
$sessionid = $cpsession['sessionid'];
|
||||
$attributes = array();
|
||||
if (!empty($cpsession['session_timeout']))
|
||||
$attributes['session_timeout'] = $cpsession['session_timeout'];
|
||||
if (!empty($cpsession['session_terminate_time']))
|
||||
$attributes['session_terminate_time'] = $cpsession['session_terminate_time'];
|
||||
|
||||
include("{$g['varetc_path']}/captiveportal-{$cpzone}-logout.html");
|
||||
ob_flush();
|
||||
return;
|
||||
} else if ($orig_host != $ourhostname) {
|
||||
/* the client thinks it's connected to the desired web server, but instead
|
||||
it's connected to us. Issue a redirect... */
|
||||
$protocol = (isset($cpcfg['httpslogin'])) ? 'https://' : 'http://';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user