Skip to content

Commit

Permalink
feat: docs and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rushtong committed Sep 14, 2024
1 parent f2bb354 commit 28b4231
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/libs/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { v4 as uuid } from 'uuid';

// Storage Variables
const CurrentUser = 'CurrentUser'; // System user
const GoogleUser = 'Gapi'; // Google user info, including token
const OidcUser = 'OidcUser'; // Google user info, including token
const UserIsLogged = 'isLogged'; // User log status flag
const OidcUser = 'OidcUser'; // B2C Tenant user info, including token
const UserIsLogged = 'isLogged'; // User authenticated status flag
const UserSettings = 'UserSettings'; // Different user settings for saving statuses in the app
const anonymousId = 'anonymousId';
const ENV = 'env';
Expand All @@ -15,6 +14,10 @@ export const Storage = {
sessionStorage.clear();
},

/**
* This user object is what we save in Consent
* @param data
*/
setCurrentUser: data => {
sessionStorage.setItem(CurrentUser, JSON.stringify(data));
},
Expand All @@ -23,10 +26,6 @@ export const Storage = {
return sessionStorage.getItem(CurrentUser) ? JSON.parse(sessionStorage.getItem(CurrentUser)) : null;
},

getCurrentUserRoles: () => {
return sessionStorage.getItem(CurrentUser) ? JSON.parse(sessionStorage.getItem(CurrentUser)).roles : null;
},

getCurrentUserSettings: (key) => {
const id = Storage.getCurrentUser()?.userId || '';
const userSettings = JSON.parse(sessionStorage.getItem(UserSettings)) || {};
Expand All @@ -51,6 +50,10 @@ export const Storage = {
sessionStorage.setItem(UserSettings, JSON.stringify(userSettings));
},

/**
* This user object is returned from our B2C tenant
* @param oidcUser
*/
setOidcUser: oidcUser => {
sessionStorage.setItem(OidcUser, JSON.stringify(oidcUser));
},
Expand Down

0 comments on commit 28b4231

Please sign in to comment.