Browse Source

fix(admin-ui): Fix issue with failed login caused by localstorage change

Fixes #2207
Michael Bromley 2 years ago
parent
commit
c96417ff7b

+ 20 - 1
packages/admin-ui/src/lib/core/src/providers/local-storage/local-storage.service.ts

@@ -30,6 +30,21 @@ export type LocalStorageLocationBasedTypeMap = {
     shippingTestAddress: any;
 };
 
+/**
+ * These keys are stored specific to a particular AdminId, so that multiple
+ * admins can use the same browser without interfering with each other's data.
+ */
+const ADMIN_SPECIFIC_KEYS: Array<keyof LocalStorageTypeMap> = [
+    'activeTheme',
+    'uiLanguageCode',
+    'uiLocale',
+    'contentLanguageCode',
+    'dashboardWidgetLayout',
+    'activeTheme',
+    'livePreviewCollectionContents',
+    'dataTableConfig',
+];
+
 const PREFIX = 'vnd_';
 
 /**
@@ -111,6 +126,10 @@ export class LocalStorageService {
     }
 
     private keyName(key: keyof LocalStorageTypeMap): string {
-        return `${PREFIX}_${this.adminId}_${key}`;
+        if (ADMIN_SPECIFIC_KEYS.includes(key)) {
+            return `${PREFIX}_${this.adminId}_${key}`;
+        } else {
+            return `${PREFIX}_${key}`;
+        }
     }
 }