summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2015-08-25 14:41:42 -0400
committerjim-p <jimp@pfsense.org>2015-08-25 14:41:42 -0400
commitd2ecbddc79a9b67cae52fca6cd3b7bebd758b047 (patch)
treede3178137611050d9516f12255208847a1cfae85 /src
parent5240564c054781330437c1767d61114d33bf7bb8 (diff)
downloadpfsense-d2ecbddc79a9b67cae52fca6cd3b7bebd758b047.zip
pfsense-d2ecbddc79a9b67cae52fca6cd3b7bebd758b047.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/etc/inc/captiveportal.inc11
-rw-r--r--src/usr/local/captiveportal/index.php19
2 files changed, 29 insertions, 1 deletions
diff --git a/src/etc/inc/captiveportal.inc b/src/etc/inc/captiveportal.inc
index bd294e4..e95cc75 100644
--- a/src/etc/inc/captiveportal.inc
+++ b/src/etc/inc/captiveportal.inc
@@ -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;
+ }
+}
?>
diff --git a/src/usr/local/captiveportal/index.php b/src/usr/local/captiveportal/index.php
index d450233..b851e91 100644
--- a/src/usr/local/captiveportal/index.php
+++ b/src/usr/local/captiveportal/index.php
@@ -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://';
OpenPOWER on IntegriCloud