{"action":"created","issue":{"url":"https://api.github.com/repos/auth0/angular-storage/issues/30","labels_url":"https://api.github.com/repos/auth0/angular-storage/issues/30/labels{/name}","comments_url":"https://api.github.com/repos/auth0/angular-storage/issues/30/comments","events_url":"https://api.github.com/repos/auth0/angular-storage/issues/30/events","html_url":"https://github.com/auth0/angular-storage/issues/30","id":84067518,"number":30,"title":"Proper handling of localStorage disabled check","user":{"login":"ako977","id":1375416,"avatar_url":"https://avatars.githubusercontent.com/u/1375416?v=3","gravatar_id":"","url":"https://api.github.com/users/ako977","html_url":"https://github.com/ako977","followers_url":"https://api.github.com/users/ako977/followers","following_url":"https://api.github.com/users/ako977/following{/other_user}","gists_url":"https://api.github.com/users/ako977/gists{/gist_id}","starred_url":"https://api.github.com/users/ako977/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ako977/subscriptions","organizations_url":"https://api.github.com/users/ako977/orgs","repos_url":"https://api.github.com/users/ako977/repos","events_url":"https://api.github.com/users/ako977/events{/privacy}","received_events_url":"https://api.github.com/users/ako977/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-06-02T15:15:16Z","updated_at":"2015-07-21T14:32:34Z","closed_at":"2015-06-04T13:05:24Z","body":"In angular-storage on line 86 a check is performed for localStorage enabled on the browser by \r\n\r\n    var localStorageAvailable = !!$window.localStorage;\r\n\r\nThis check is not adequate enough bc/ at least in chrome, you get an error: \r\n    Error: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.\r\nI recommend removing that line and rather just using the try catch that is performed below as: \r\n      \r\n    try {\r\n        $window.localStorage.setItem('testKey', 'test');\r\n        $window.localStorage.removeItem('testKey');\r\n        var localStorageAvailable = true;\r\n      } catch(e) {\r\n        var localStorageAvailable = false;\r\n    }\r\n\r\nThis way chrome wouldn't break the script on the site.\r\nThis code executes before any other check in other app modules can mitigate this (for angularjs apps with localStorage turned off) This would be in order to even show a warning notice to the user.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/auth0/angular-storage/issues/comments/123340662","html_url":"https://github.com/auth0/angular-storage/issues/30#issuecomment-123340662","issue_url":"https://api.github.com/repos/auth0/angular-storage/issues/30","id":123340662,"user":{"login":"jercoh","id":1455234,"avatar_url":"https://avatars.githubusercontent.com/u/1455234?v=3","gravatar_id":"","url":"https://api.github.com/users/jercoh","html_url":"https://github.com/jercoh","followers_url":"https://api.github.com/users/jercoh/followers","following_url":"https://api.github.com/users/jercoh/following{/other_user}","gists_url":"https://api.github.com/users/jercoh/gists{/gist_id}","starred_url":"https://api.github.com/users/jercoh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jercoh/subscriptions","organizations_url":"https://api.github.com/users/jercoh/orgs","repos_url":"https://api.github.com/users/jercoh/repos","events_url":"https://api.github.com/users/jercoh/events{/privacy}","received_events_url":"https://api.github.com/users/jercoh/received_events","type":"User","site_admin":false},"created_at":"2015-07-21T14:32:34Z","updated_at":"2015-07-21T14:32:34Z","body":"Hi, I've made another pull request to handle sessionStorage check as well. I was getting an error in Chrome. "}}