From f3c349baac8ff1fcf494f36ee4a264cf1b9332e4 Mon Sep 17 00:00:00 2001 From: Gregg Tavares Date: Fri, 21 Nov 2014 18:13:43 -0800 Subject: [PATCH] make AppleCaptivePortalHandle able to change options after initialziation --- server/apple-captive-portal-handler.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/server/apple-captive-portal-handler.js b/server/apple-captive-portal-handler.js index 38497ea0..4714e250 100644 --- a/server/apple-captive-portal-handler.js +++ b/server/apple-captive-portal-handler.js @@ -74,14 +74,29 @@ var url = require('url'); * * @constructor * @private - * @param {AppleCaptivePortalHandler~Options} sendFileFn + * @param {AppleCaptivePortalHandler~Options} options options */ var AppleCaptivePortalHandler = function(options) { // This is a total guess. I'm assuming iOS sends a unique URL. I can use that to hopefully // return my redirection page the first time and apple's success page the second time this.sessions = {}; - this.options = options; + this.options = {}; this.firstPath = "/enter-name.html"; + this.setOptions(options); +}; + +/** + * Sets options + * + * @param {AppleCaptivePortalHandler~Options} options options + */ +AppleCaptivePortalHandler.prototype.setOptions = function(options) { + ["sendFileFn", "address", "port", "baseDir"].forEach(function(key) { + var value = options[key]; + if (value !== undefined) { + this.options[key] = value; + } + }.bind(this)); }; /**