diff --git a/README.md b/README.md index aada9d0..44d701a 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,12 @@ Include the gem in your Gemfile: gem "queueit_knownuserv3" ``` -You can find the latest released version [here](https://github.com/queueit/KnownUser.V3.RubyOnRails/releases/latest) and distributed +You can find the latest released version [here](https://github.com/queueit/KnownUser.V3.RubyOnRails/releases/latest) and distributed gem [here](https://rubygems.org/gems/queueit_knownuserv3). ## Implementation -If we have the `integrationconfig.json` copied in the rails app folder then +If we have the `integrationconfig.json` copied in the rails app folder then the following example of a controller is all that is needed to validate that a user has been through the queue: ```ruby @@ -33,9 +33,9 @@ class ResourceController < ApplicationController pattern = Regexp.new("([\\?&])(" + QueueIt::KnownUser::QUEUEIT_TOKEN_KEY + "=[^&]*)", Regexp::IGNORECASE) requestUrlWithoutToken = requestUrl.gsub(pattern, '') # The requestUrlWithoutToken is used to match Triggers and as the Target url (where to return the users to). - # It is therefor important that this is exactly the url of the users browsers. So, if your webserver is - # behind e.g. a load balancer that modifies the host name or port, reformat requestUrlWithoutToken before proceeding. - # Example of replacing host from requestUrlWithoutToken + # It is therefor important that this is exactly the url of the users browsers. So, if your webserver is + # behind e.g. a load balancer that modifies the host name or port, reformat requestUrlWithoutToken before proceeding. + # Example of replacing host from requestUrlWithoutToken #requestUriNoToken = URI.parse(requestUrlWithoutToken) #requestUriNoToken.host = "INSERT-REPLACEMENT-HOST-HERE" #requestUrlWithoutToken = requestUriNoToken.to_s @@ -43,17 +43,17 @@ class ResourceController < ApplicationController queueitToken = request.query_parameters[QueueIt::KnownUser::QUEUEIT_TOKEN_KEY.to_sym] # Initialize the SDK with the rails http context (must be done before calling validateRequestByIntegrationConfig) - QueueIt::HttpContextProvider::setHttpContext(QueueIt::RailsHttpContext.new(request)) + queue_it = QueueIt::KnownUser.new(QueueIt::RailsHttpContext.new(request)) # Verify if the user has been through the queue - validationResult = QueueIt::KnownUser.validateRequestByIntegrationConfig( + validationResult = queue_it.validateRequestByIntegrationConfig( requestUrlWithoutToken, queueitToken, configJson, customerId, secretKey) - if(validationResult.doRedirect) + if(validationResult.doRedirect) #Adding no cache headers to prevent browsers to cache requests response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate, max-age=0" response.headers["Pragma"] = "no-cache" @@ -68,10 +68,10 @@ class ResourceController < ApplicationController ajaxQueueRedirectHeaderName = validationResult.getAjaxQueueRedirectHeaderKey() response.headers[ajaxQueueRedirectHeaderName] = validationResult.getAjaxRedirectUrl() response.headers["Access-Control-Expose-Headers"] = ajaxQueueRedirectHeaderName - end + end else - # Request can continue, we remove queueittoken from url to avoid sharing of user specific token - if(requestUrl != requestUrlWithoutToken && validationResult.actionType == "Queue") + # Request can continue, we remove queueittoken from url to avoid sharing of user specific token + if(requestUrl != requestUrlWithoutToken && validationResult.actionType == "Queue") redirect_to requestUrlWithoutToken end end @@ -88,18 +88,18 @@ end ## Implementation using inline queue configuration -Specify the configuration in code without using the Trigger/Action paradigm. In this case it is important *only to queue-up page requests* and not requests for resources. -This can be done by adding custom filtering logic before caling the `QueueIt::KnownUser.resolveQueueRequestByLocalConfig` method. +Specify the configuration in code without using the Trigger/Action paradigm. In this case it is important *only to queue-up page requests* and not requests for resources. +This can be done by adding custom filtering logic before caling the `QueueIt::KnownUser.resolveQueueRequestByLocalConfig` method. The following is an example of how to specify the configuration in code: ```ruby -class ResourceController < ApplicationController - def index - begin +class ResourceController < ApplicationController + def index + begin customerId = "" # Your Queue-it customer ID - secretKey = "" # Your 72 char secret key as specified in Go Queue-it self-service platform + secretKey = "" # Your 72 char secret key as specified in Go Queue-it self-service platform eventConfig = QueueIt::QueueEventConfig.new eventConfig.eventId = "" # ID of the queue to use eventConfig.queueDomain = "xxx.queue-it.net" # Domain name of the queue. @@ -113,17 +113,17 @@ class ResourceController < ApplicationController queueitToken = request.query_parameters[QueueIt::KnownUser::QUEUEIT_TOKEN_KEY.to_sym] # Initialize the SDK with the rails http context (must be done before calling validateRequestByIntegrationConfig) - QueueIt::HttpContextProvider::setHttpContext(QueueIt::RailsHttpContext.new(request)) + qit_known_user = QueueIt::KnownUser.new(QueueIt::RailsHttpContext.new(request)) # Verify if the user has been through the queue - validationResult = QueueIt::KnownUser.resolveQueueRequestByLocalConfig( + validationResult = qit_known_user.resolveQueueRequestByLocalConfig( requestUrl, queueitToken, eventConfig, customerId, secretKey) - if(validationResult.doRedirect) + if(validationResult.doRedirect) #Adding no cache headers to prevent browsers to cache requests response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate, max-age=0" response.headers["Pragma"] = "no-cache" @@ -139,7 +139,7 @@ class ResourceController < ApplicationController response.headers["Access-Control-Expose-Headers"] = ajaxQueueRedirectHeaderName end else - # Request can continue - we remove queueittoken form querystring parameter to avoid sharing of user specific token + # Request can continue - we remove queueittoken form querystring parameter to avoid sharing of user specific token pattern = Regexp.new("([\\?&])(" + QueueIt::KnownUser::QUEUEIT_TOKEN_KEY + "=[^&]*)", Regexp::IGNORECASE) requestUrlWithoutToken = requestUrl.gsub(pattern, '') @@ -163,20 +163,18 @@ end The connector supports triggering on request body content. An example could be a POST call with specific item ID where you want end-users to queue up for. For this to work, you will need to contact Queue-it support or enable request body triggers in your integration settings in your GO Queue-it platform account. -Once enabled you will need to update your integration so request body is available for the connector. +Once enabled you will need to update your integration so request body is available for the connector. You need to create a custom RailsHttpContext similar to this one (make sure to inherit from `QueueIt::RailsHttpContext`): ```ruby class RailsHttpContextWithRequestBody < QueueIt::RailsHttpContext - @request - def initialize(request) super @request = request end def requestBodyAsString - return @request.raw_post + @request.raw_post end end ``` diff --git a/lib/queueit_knownuserv3/httpcontext_provider.rb b/lib/queueit_knownuserv3/httpcontext_provider.rb index 01c1f29..ba0ef77 100644 --- a/lib/queueit_knownuserv3/httpcontext_provider.rb +++ b/lib/queueit_knownuserv3/httpcontext_provider.rb @@ -1,6 +1,5 @@ module QueueIt class IHttpContext - def userAgent raise 'userAgent not implemented' end @@ -24,70 +23,35 @@ def cookieManager def requestBodyAsString raise 'requestBodyAsString not implemented' end - end class RailsHttpContext < IHttpContext - @request - def initialize(request) @request = request end def userAgent - return @request.user_agent + @request.user_agent end def headers - return @request.headers + @request.headers end def url - return @request.env["rack.url_scheme"] + "://" + @request.env["HTTP_HOST"] + @request.original_fullpath + @request.env["rack.url_scheme"] + "://" + @request.env["HTTP_HOST"] + @request.original_fullpath end def userHostAddress - return @request.remote_ip + @request.remote_ip end def cookieManager - cookieManager = CookieManager.new(@request.cookie_jar) - return cookieManager + CookieManager.new(@request.cookie_jar) end def requestBodyAsString - return '' - end - - end - - # Used to initialize SDK for each request - class SDKInitializer - - def self.setHttpContext(httpContext) - if (httpContext.class < IHttpContext) - HttpContextProvider.setHttpContext(httpContext) - else - raise "httpContext must be a subclass of IHttpContext (e.g. MyHttpContext < IHttpContext)" - end + '' end - - end - - class HttpContextProvider - @@httpContext - - def self.httpContext - if (defined?(@@httpContext)) - return @@httpContext - else - raise "Please initialize the SDK using SDKInitializer.setHttpContext(httpContext) method" - end - end - - def self.setHttpContext(httpContext) - @@httpContext = httpContext - end - end end diff --git a/lib/queueit_knownuserv3/known_user.rb b/lib/queueit_knownuserv3/known_user.rb index d5e58ec..dba02f8 100644 --- a/lib/queueit_knownuserv3/known_user.rb +++ b/lib/queueit_knownuserv3/known_user.rb @@ -2,179 +2,16 @@ require 'json' module QueueIt - class KnownUser QUEUEIT_TOKEN_KEY = "queueittoken" QUEUEIT_DEBUG_KEY = "queueitdebug" QUEUEIT_AJAX_HEADER_KEY = "x-queueit-ajaxpageurl" - @@userInQueueService = nil - def self.getUserInQueueService() - if (@@userInQueueService == nil) - return UserInQueueService.new(UserInQueueStateCookieRepository.new(HttpContextProvider.httpContext.cookieManager)) - end - - return @@userInQueueService - end - private_class_method :getUserInQueueService - - def self.isQueueAjaxCall - headers = HttpContextProvider.httpContext.headers - return headers[QUEUEIT_AJAX_HEADER_KEY] != nil - end - private_class_method :isQueueAjaxCall - - def self.generateTargetUrl(originalTargetUrl) - unless isQueueAjaxCall() - return originalTargetUrl - end - headers = HttpContextProvider.httpContext.headers - return CGI::unescape(headers[QUEUEIT_AJAX_HEADER_KEY]) - end - private_class_method :generateTargetUrl - - def self.convertToInt(value) - begin - converted = Integer(value) - rescue - converted = 0 - end - return converted - end - private_class_method :convertToInt - - def self.logMoreRequestDetails(debugEntries) - httpContext = HttpContextProvider.httpContext - headers = httpContext.headers - - debugEntries["ServerUtcTime"] = Time.now.utc.iso8601 - debugEntries["RequestIP"] = httpContext.userHostAddress - debugEntries["RequestHttpHeader_Via"] = headers["via"] - debugEntries["RequestHttpHeader_Forwarded"] = headers["forwarded"] - debugEntries["RequestHttpHeader_XForwardedFor"] = headers["x-forwarded-for"] - debugEntries["RequestHttpHeader_XForwardedHost"] = headers["x-forwarded-host"] - debugEntries["RequestHttpHeader_XForwardedProto"] = headers["x-forwarded-proto"] - end - private_class_method :logMoreRequestDetails - - def self.setDebugCookie(debugEntries) - if(debugEntries == nil || debugEntries.length == 0) - return - end - - cookieManager = HttpContextProvider.httpContext.cookieManager - cookieValue = '' - debugEntries.each do |entry| - cookieValue << (entry[0].to_s + '=' + entry[1].to_s + '|') - end - cookieValue = cookieValue.chop # remove trailing char - cookieManager.setCookie(QUEUEIT_DEBUG_KEY, cookieValue, nil, nil, false, false) - end - private_class_method :setDebugCookie - - def self._resolveQueueRequestByLocalConfig(targetUrl, queueitToken, queueConfig, customerId, secretKey, debugEntries, isDebug) - - if(isDebug) - debugEntries["SdkVersion"] = UserInQueueService::SDK_VERSION - debugEntries["Runtime"] = getRuntime() - debugEntries["TargetUrl"] = targetUrl - debugEntries["QueueitToken"] = queueitToken - debugEntries["OriginalUrl"] = getRealOriginalUrl() - if(queueConfig == nil) - debugEntries["QueueConfig"] = "NULL" - else - debugEntries["QueueConfig"] = queueConfig.toString() - end - logMoreRequestDetails(debugEntries) - end - - if(Utils.isNilOrEmpty(customerId)) - raise KnownUserError, "customerId can not be nil or empty." - end - - if(Utils.isNilOrEmpty(secretKey)) - raise KnownUserError, "secretKey can not be nil or empty." - end - - if(queueConfig == nil) - raise KnownUserError, "queueConfig can not be nil." - end - - if(Utils.isNilOrEmpty(queueConfig.eventId)) - raise KnownUserError, "queueConfig.eventId can not be nil or empty." - end - - if(Utils.isNilOrEmpty(queueConfig.queueDomain)) - raise KnownUserError, "queueConfig.queueDomain can not be nil or empty." - end - - minutes = convertToInt(queueConfig.cookieValidityMinute) - if(minutes <= 0) - raise KnownUserError, "queueConfig.cookieValidityMinute should be integer greater than 0." - end - - if(![true, false].include? queueConfig.extendCookieValidity) - raise KnownUserError, "queueConfig.extendCookieValidity should be valid boolean." - end - - userInQueueService = getUserInQueueService() - result = userInQueueService.validateQueueRequest(targetUrl, queueitToken, queueConfig, customerId, secretKey) - result.isAjaxResult = isQueueAjaxCall() - - return result + def initialize(httpContext) + @httpContext = httpContext end - private_class_method :_resolveQueueRequestByLocalConfig - - def self._cancelRequestByLocalConfig(targetUrl, queueitToken, cancelConfig, customerId, secretKey, debugEntries, isDebug) - targetUrl = generateTargetUrl(targetUrl) - - if(isDebug) - debugEntries["SdkVersion"] = UserInQueueService::SDK_VERSION - debugEntries["Runtime"] = getRuntime() - debugEntries["TargetUrl"] = targetUrl - debugEntries["QueueitToken"] = queueitToken - debugEntries["OriginalUrl"] = getRealOriginalUrl() - if(cancelConfig == nil) - debugEntries["CancelConfig"] = "NULL" - else - debugEntries["CancelConfig"] = cancelConfig.toString() - end - logMoreRequestDetails(debugEntries) - end - - if(Utils.isNilOrEmpty(targetUrl)) - raise KnownUserError, "targetUrl can not be nil or empty." - end - - if(Utils.isNilOrEmpty(customerId)) - raise KnownUserError, "customerId can not be nil or empty." - end - - if(Utils.isNilOrEmpty(secretKey)) - raise KnownUserError, "secretKey can not be nil or empty." - end - if(cancelConfig == nil) - raise KnownUserError, "cancelConfig can not be nil." - end - - if(Utils.isNilOrEmpty(cancelConfig.eventId)) - raise KnownUserError, "cancelConfig.eventId can not be nil or empty." - end - - if(Utils.isNilOrEmpty(cancelConfig.queueDomain)) - raise KnownUserError, "cancelConfig.queueDomain can not be nil or empty." - end - - userInQueueService = getUserInQueueService() - result = userInQueueService.validateCancelRequest(targetUrl, cancelConfig, customerId, secretKey) - result.isAjaxResult = isQueueAjaxCall() - - return result - end - private_class_method :_cancelRequestByLocalConfig - - def self.extendQueueCookie(eventId, cookieValidityMinute, cookieDomain, isCookieHttpOnly, isCookieSecure, secretKey) + def extendQueueCookie(eventId, cookieValidityMinute, cookieDomain, isCookieHttpOnly, isCookieSecure, secretKey) if(Utils.isNilOrEmpty(eventId)) raise KnownUserError, "eventId can not be nil or empty." end @@ -192,7 +29,7 @@ def self.extendQueueCookie(eventId, cookieValidityMinute, cookieDomain, isCookie userInQueueService.extendQueueCookie(eventId, cookieValidityMinute, cookieDomain, isCookieHttpOnly, isCookieSecure, secretKey) end - def self.resolveQueueRequestByLocalConfig(targetUrl, queueitToken, queueConfig, customerId, secretKey) + def resolveQueueRequestByLocalConfig(targetUrl, queueitToken, queueConfig, customerId, secretKey) debugEntries = Hash.new connectorDiagnostics = ConnectorDiagnostics.verify(customerId, secretKey, queueitToken) @@ -212,7 +49,7 @@ def self.resolveQueueRequestByLocalConfig(targetUrl, queueitToken, queueConfig, end end - def self.validateRequestByIntegrationConfig(currentUrlWithoutQueueITToken, queueitToken, integrationConfigJson, customerId, secretKey) + def validateRequestByIntegrationConfig(currentUrlWithoutQueueITToken, queueitToken, integrationConfigJson, customerId, secretKey) debugEntries = Hash.new customerIntegration = Hash.new connectorDiagnostics = ConnectorDiagnostics.verify(customerId, secretKey, queueitToken) @@ -249,7 +86,7 @@ def self.validateRequestByIntegrationConfig(currentUrlWithoutQueueITToken, queue end integrationEvaluator = IntegrationEvaluator.new - matchedConfig = integrationEvaluator.getMatchedIntegrationConfig(customerIntegration, currentUrlWithoutQueueITToken, HttpContextProvider.httpContext) + matchedConfig = integrationEvaluator.getMatchedIntegrationConfig(customerIntegration, currentUrlWithoutQueueITToken, @httpContext) if(connectorDiagnostics.isEnabled) if(matchedConfig == nil) @@ -290,7 +127,7 @@ def self.validateRequestByIntegrationConfig(currentUrlWithoutQueueITToken, queue end end - def self.handleQueueAction(currentUrlWithoutQueueITToken, queueitToken, customerIntegration, customerId, secretKey, matchedConfig, debugEntries, isDebug) + def handleQueueAction(currentUrlWithoutQueueITToken, queueitToken, customerIntegration, customerId, secretKey, matchedConfig, debugEntries, isDebug) queueConfig = QueueEventConfig.new queueConfig.eventId = matchedConfig["EventId"] queueConfig.layoutName = matchedConfig["LayoutName"] @@ -316,7 +153,7 @@ def self.handleQueueAction(currentUrlWithoutQueueITToken, queueitToken, customer return _resolveQueueRequestByLocalConfig(targetUrl, queueitToken, queueConfig, customerId, secretKey, debugEntries, isDebug) end - def self.handleCancelAction(currentUrlWithoutQueueITToken, queueitToken, customerIntegration, customerId, secretKey, matchedConfig, debugEntries, isDebug) + def handleCancelAction(currentUrlWithoutQueueITToken, queueitToken, customerIntegration, customerId, secretKey, matchedConfig, debugEntries, isDebug) cancelConfig = CancelEventConfig.new cancelConfig.eventId = matchedConfig["EventId"] cancelConfig.queueDomain = matchedConfig["QueueDomain"] @@ -329,7 +166,7 @@ def self.handleCancelAction(currentUrlWithoutQueueITToken, queueitToken, custome return _cancelRequestByLocalConfig(currentUrlWithoutQueueITToken, queueitToken, cancelConfig, customerId, secretKey, debugEntries, isDebug) end - def self.cancelRequestByLocalConfig(targetUrl, queueitToken, cancelConfig, customerId, secretKey) + def cancelRequestByLocalConfig(targetUrl, queueitToken, cancelConfig, customerId, secretKey) debugEntries = Hash.new connectorDiagnostics = ConnectorDiagnostics.verify(customerId, secretKey, queueitToken) @@ -348,15 +185,131 @@ def self.cancelRequestByLocalConfig(targetUrl, queueitToken, cancelConfig, custo end end - def self.getRealOriginalUrl() - return HttpContextProvider.httpContext.url + def getRealOriginalUrl + return @httpContext.url # RoR could modify request.original_url if request contains x-forwarded-host/proto http headers. # Therefore we need this method to be able to access the 'real' original url. #return request.env["rack.url_scheme"] + "://" + request.env["HTTP_HOST"] + request.original_fullpath end - def self.getRuntime() - return RUBY_VERSION.to_s + def getRuntime + RUBY_VERSION.to_s + end + + private + + def getUserInQueueService + @userInQueueService ||= UserInQueueService.new(UserInQueueStateCookieRepository.new(@httpContext.cookieManager)) + end + + def isQueueAjaxCall + headers = @httpContext.headers + + headers[QUEUEIT_AJAX_HEADER_KEY] != nil + end + + def generateTargetUrl(originalTargetUrl) + return originalTargetUrl unless isQueueAjaxCall + + headers = @httpContext.headers + + CGI.unescape(headers[QUEUEIT_AJAX_HEADER_KEY]) + end + + def convertToInt(value) + Integer(value) rescue 0 + end + + def logMoreRequestDetails(debugEntries) + headers = @httpContext.headers + + debugEntries["ServerUtcTime"] = Time.now.utc.iso8601 + debugEntries["RequestIP"] = @httpContext.userHostAddress + debugEntries["RequestHttpHeader_Via"] = headers["via"] + debugEntries["RequestHttpHeader_Forwarded"] = headers["forwarded"] + debugEntries["RequestHttpHeader_XForwardedFor"] = headers["x-forwarded-for"] + debugEntries["RequestHttpHeader_XForwardedHost"] = headers["x-forwarded-host"] + debugEntries["RequestHttpHeader_XForwardedProto"] = headers["x-forwarded-proto"] + end + + def setDebugCookie(debugEntries) + return if debugEntries == nil || debugEntries.length == 0 + + cookieManager = @httpContext.cookieManager + cookieValue = +'' + debugEntries.each do |entry| + cookieValue << (entry[0].to_s + '=' + entry[1].to_s + '|') + end + cookieValue = cookieValue.chop # remove trailing char + cookieManager.setCookie(QUEUEIT_DEBUG_KEY, cookieValue, nil, nil, false, false) + end + + def _resolveQueueRequestByLocalConfig(targetUrl, queueitToken, queueConfig, customerId, secretKey, debugEntries, isDebug) + if(isDebug) + debugEntries["SdkVersion"] = UserInQueueService::SDK_VERSION + debugEntries["Runtime"] = getRuntime + debugEntries["TargetUrl"] = targetUrl + debugEntries["QueueitToken"] = queueitToken + debugEntries["OriginalUrl"] = getRealOriginalUrl + if queueConfig == nil + debugEntries["QueueConfig"] = "NULL" + else + debugEntries["QueueConfig"] = queueConfig.toString + end + logMoreRequestDetails(debugEntries) + end + + raise KnownUserError, "customerId can not be nil or empty." if Utils.isNilOrEmpty(customerId) + raise KnownUserError, "secretKey can not be nil or empty." if Utils.isNilOrEmpty(secretKey) + raise KnownUserError, "queueConfig can not be nil." if queueConfig == nil + raise KnownUserError, "queueConfig.eventId can not be nil or empty." if Utils.isNilOrEmpty(queueConfig.eventId) + raise KnownUserError, "queueConfig.queueDomain can not be nil or empty." if Utils.isNilOrEmpty(queueConfig.queueDomain) + + minutes = convertToInt(queueConfig.cookieValidityMinute) + if(minutes <= 0) + raise KnownUserError, "queueConfig.cookieValidityMinute should be integer greater than 0." + end + + if(![true, false].include? queueConfig.extendCookieValidity) + raise KnownUserError, "queueConfig.extendCookieValidity should be valid boolean." + end + + userInQueueService = getUserInQueueService + result = userInQueueService.validateQueueRequest(targetUrl, queueitToken, queueConfig, customerId, secretKey) + result.isAjaxResult = isQueueAjaxCall + + return result + end + + def _cancelRequestByLocalConfig(targetUrl, queueitToken, cancelConfig, customerId, secretKey, debugEntries, isDebug) + targetUrl = generateTargetUrl(targetUrl) + + if isDebug + debugEntries["SdkVersion"] = UserInQueueService::SDK_VERSION + debugEntries["Runtime"] = getRuntime() + debugEntries["TargetUrl"] = targetUrl + debugEntries["QueueitToken"] = queueitToken + debugEntries["OriginalUrl"] = getRealOriginalUrl() + if(cancelConfig == nil) + debugEntries["CancelConfig"] = "NULL" + else + debugEntries["CancelConfig"] = cancelConfig.toString() + end + logMoreRequestDetails(debugEntries) + end + + raise KnownUserError, "targetUrl can not be nil or empty." if Utils.isNilOrEmpty(targetUrl) + raise KnownUserError, "customerId can not be nil or empty." if Utils.isNilOrEmpty(customerId) + raise KnownUserError, "secretKey can not be nil or empty." if Utils.isNilOrEmpty(secretKey) + raise KnownUserError, "cancelConfig can not be nil." if cancelConfig == nil + raise KnownUserError, "cancelConfig.eventId can not be nil or empty." if Utils.isNilOrEmpty(cancelConfig.eventId) + raise KnownUserError, "cancelConfig.queueDomain can not be nil or empty." if Utils.isNilOrEmpty(cancelConfig.queueDomain) + + userInQueueService = getUserInQueueService + result = userInQueueService.validateCancelRequest(targetUrl, cancelConfig, customerId, secretKey) + result.isAjaxResult = isQueueAjaxCall + + result end end @@ -381,30 +334,23 @@ def setCookie(name, value, expire, domain, isHttpOnly, isSecure) deleteCookie = Utils.isNilOrEmpty(value) noExpire = Utils.isNilOrEmpty(expire) - if(noDomain) - if(deleteCookie) + if noDomain + if deleteCookie @cookies.delete(key) + elsif noExpire + @cookies[key] = { value: value, httponly: isHttpOnly, secure: isSecure } else - if(noExpire) - @cookies[key] = { :value => value, :httponly => isHttpOnly, :secure => isSecure } - else - @cookies[key] = { :value => value, :expires => expire, :httponly => isHttpOnly, :secure => isSecure } - end + @cookies[key] = { value: value, expires: expire, httponly: isHttpOnly, secure: isSecure } end else - if(deleteCookie) - @cookies.delete(key, :domain => domain) + if deleteCookie + @cookies.delete(key, domain: domain) + elsif noExpire + @cookies[key] = { value: value, domain: domain, httponly: isHttpOnly, secure: isSecure } else - if(noExpire) - @cookies[key] = { :value => value, :domain => domain, :httponly => isHttpOnly, :secure => isSecure } - else - @cookies[key] = { :value => value, :expires => expire, :domain => domain, :httponly => isHttpOnly, :secure => isSecure } - end + @cookies[key] = { value: value, expires: expire, domain: domain, httponly: isHttpOnly, secure: isSecure } end end end end end - - -