Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/api/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ const fetchTokenApi = (username, password, tokenDetails = null) => {
body: tokenDetails || {
username,
password,
token_name: randomString(tokenNameLength),
token_scope: tokenScope,
token_expire: getDate(tokenExpiryDays),
tokenName: randomString(tokenNameLength),
tokenScope: tokenScope,
tokenExpire: getDate(tokenExpiryDays),
},
addGroupName: false,
});
Expand Down
6 changes: 3 additions & 3 deletions src/api/auth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ describe("auth", () => {
body: {
username,
password,
token_name: randomString,
token_scope: tokenScope,
token_expire: getDate(tokenExpiryDays),
tokenName: randomString,
tokenScope: tokenScope,
tokenExpire: getDate(tokenExpiryDays),
},
addGroupName: false,
})
Expand Down
11 changes: 10 additions & 1 deletion src/shared/storageHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,16 @@ export const setLocalStorage = (key, value) => {
// Get from localstorage
export const getLocalStorage = (key) => {
if (typeof window !== "undefined") {
return JSON.parse(localStorage.getItem(key));
const item = localStorage.getItem(key);
if (item === null || item === undefined || item === "undefined") {
return null;
}
try {
return JSON.parse(item);
} catch (error) {
console.error("Error parsing localStorage item", error);
return null;
}
}
return null;
};
Expand Down