You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

authScopeHelpers.js 822B

123456789101112131415161718192021222324252627282930313233
  1. import { SESSION_STORAGE_SCOPE } from '../../constants/sessionStorage';
  2. export function authScopeGetHelper(key) {
  3. if (sessionStorage.getItem(SESSION_STORAGE_SCOPE)) {
  4. return JSON.parse(sessionStorage.getItem(key));
  5. }
  6. return JSON.parse(localStorage.getItem(key));
  7. }
  8. export function authScopeStringGetHelper(key) {
  9. return localStorage.getItem(key);
  10. }
  11. export function authScopeSetHelper(key, value) {
  12. if (sessionStorage.getItem(SESSION_STORAGE_SCOPE)) {
  13. sessionStorage.setItem(key, value);
  14. } else {
  15. localStorage.setItem(key, value);
  16. }
  17. }
  18. export function authScopeRemoveHelper(key) {
  19. if (sessionStorage.getItem(SESSION_STORAGE_SCOPE)) {
  20. sessionStorage.removeItem(key);
  21. } else {
  22. localStorage.removeItem(key);
  23. }
  24. }
  25. export function authScopeClearHelper() {
  26. localStorage.clear();
  27. }