Reworks also sessionStorage test because disablement of cookies might be connected with sessionStorage and localStorage. E.g. Chrome raises exception when *Storage is accessed with "Block sites from setting any data" settings set in "Content Settings/Cookies" section.

https://fedorahosted.org/freeipa/ticket/4338
--
Petr Vobornik
        
From b5ff7dfe9ba3a1f39b6e21019438c488dcc078b4 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Thu, 28 Jan 2016 16:07:06 +0100
Subject: [PATCH] webui: fail nicely if cookies are disabled

Reworks also sessionStorage test because disablement of cookies might be connected
with sessionStorage and localStorage. E.g. Chrome raises exception when *Storage
is accessed with "Block sites from setting any data" settings set in
"Content Settings/Cookies" section.

https://fedorahosted.org/freeipa/ticket/4338
---
 install/ui/src/freeipa/app_container.js | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/install/ui/src/freeipa/app_container.js b/install/ui/src/freeipa/app_container.js
index 1194fd14263a1b6f1a5a0a2fa4bc605f344ef417..b6359742317ab6e8b955cbf6b8511a5b61c06893 100644
--- a/install/ui/src/freeipa/app_container.js
+++ b/install/ui/src/freeipa/app_container.js
@@ -63,14 +63,28 @@ define([
 
             phases.on('init', lang.hitch(this, function() {
                 var deferred = new Deferred();
-                if (!window.sessionStorage) {
-                    deferred.reject({
-                        message: "Web UI requires sessionStorage enabled. " +
-                                 "This might be caused by too strict browser " +
-                                 "configuration."
-                    });
+
+                function reject(item) {
+                    var msg = "Web UI requires " + item + " enabled. " +
+                              "Possible cause: too strict browser " +
+                              "configuration.";
+                    deferred.reject({ message: msg });
                     return deferred.promise;
                 }
+
+                function testStorage(storage) {
+                    try {
+                        if (!window[storage]) return false;
+                    } catch(e) {
+                        return false;
+                    }
+                    return true;
+                }
+
+                if (!window.navigator.cookieEnabled) return reject('cookies');
+                if (!testStorage('sessionStorage')) return reject('sessionStorage');
+                if (!testStorage('localStorage')) return reject('local  Storage');
+
                 if (window.sessionStorage.getItem('logout')) {
                     window.sessionStorage.removeItem('logout');
                     var login_facet = reg.facet.get('login');
-- 
2.4.3

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to