Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A angular-storage
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Auth0
  • angular-storage
  • Issues
  • #30
Closed
Open
Issue created Jun 02, 2015 by Administrator@rootContributor

Proper handling of localStorage disabled check

Created by: ako977

In angular-storage on line 86 a check is performed for localStorage enabled on the browser by

var localStorageAvailable = !!$window.localStorage;

This check is not adequate enough bc/ at least in chrome, you get an error: Error: Failed to read the 'localStorage' property from 'Window': Access is denied for this document. I recommend removing that line and rather just using the try catch that is performed below as:

try {
    $window.localStorage.setItem('testKey', 'test');
    $window.localStorage.removeItem('testKey');
    var localStorageAvailable = true;
  } catch(e) {
    var localStorageAvailable = false;
}

This way chrome wouldn't break the script on the site. This 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.

Assignee
Assign to
Time tracking