From f110da267e7360116e563f91c20b3267d19b035f Mon Sep 17 00:00:00 2001 From: baku Date: Tue, 21 Feb 2017 00:42:01 +0100 Subject: [PATCH] Fix the CookieManager issue #172 --- index.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/index.js b/index.js index cb9cdeb..4ffbfe8 100644 --- a/index.js +++ b/index.js @@ -230,6 +230,34 @@ const ContainerService = { version: self.version }).sendEvent; + // Begin-Of-Hack + function workaroundForCookieManager(method, userContextId) { + let identity = method.call(ContextualIdentityService, userContextId); + if (!identity && userContextId) { + identity = { + userContextId, + icon: "", + color: "", + name: "Pending to be deleted", + public: true, + } + } + + return identity; + } + + let oldGetIdentityFromId = ContextualIdentityService.getIdentityFromId; + ContextualIdentityService.getIdentityFromId = function(userContextId) { + return workaroundForCookieManager(oldGetIdentityFromId, userContextId); + } + + if ("getPublicIdentityFromId" in ContextualIdentityService) { + let oldGetPublicIdentityFromId = ContextualIdentityService.getIdentityFromId; + ContextualIdentityService.getIdentityFromId = function(userContextId) { + return workaroundForCookieManager(oldGetPublicIdentityFromId, userContextId); + } + } + // End-Of-Hack }, // utility methods