diff --git a/src/api/Auth.ts b/src/api/Auth.ts index f9318c5b..b7b33c2c 100644 --- a/src/api/Auth.ts +++ b/src/api/Auth.ts @@ -248,6 +248,8 @@ export const decryptData = (value: any , isUserProfile?: boolean): string => { try { let bytes = CryptoJS.AES.decrypt(value, CRYPTO_PRIVATE_KEY); if(isUserProfile){ + const convertedData = bytes.toString(CryptoJS.enc.Utf8) + console.log() console.log(bytes , 'bytes........................')} return bytes.toString(CryptoJS.enc.Utf8); } catch (error) { @@ -257,7 +259,7 @@ export const decryptData = (value: any , isUserProfile?: boolean): string => { } } -export const setToLocalStorage = async (key: string, value: any) =>{ +export const setToLocalStorage = async (key: string, value: any , isUserProfile?: boolean) =>{ // If passed value is object then checked empty object if (typeof value === 'object' && Boolean(Object.keys(value).length <= 0)) { return; @@ -267,8 +269,12 @@ export const setToLocalStorage = async (key: string, value: any) =>{ if (typeof value === 'string' && !value?.trim()) { return; } - + if(isUserProfile){ + console.log(value, 'in set local storage value .................................')} const convertedValue = await encryptData(value) + if(isUserProfile){ + console.log(convertedValue , 'converted value in set method ..........................') + } const setValue = await localStorage.setItem(key, convertedValue as string) return true } diff --git a/src/components/Authentication/SignInUserPasskey.tsx b/src/components/Authentication/SignInUserPasskey.tsx index beb7b568..680d12c4 100644 --- a/src/components/Authentication/SignInUserPasskey.tsx +++ b/src/components/Authentication/SignInUserPasskey.tsx @@ -89,7 +89,7 @@ const SignInUserPasskey = (signInUserProps: signInUserProps) => { } await setToLocalStorage(storageKeys.PERMISSIONS, permissionArray); - await setToLocalStorage(storageKeys.USER_PROFILE, JSON.stringify(userProfile)); + await setToLocalStorage(storageKeys.USER_PROFILE, JSON.stringify(userProfile) , true); await setToLocalStorage(storageKeys.USER_EMAIL, data?.data?.email); return { role: role?.orgRole || "" diff --git a/src/components/Authentication/SignInUserPassword.tsx b/src/components/Authentication/SignInUserPassword.tsx index ea85b1bf..84f2cba3 100644 --- a/src/components/Authentication/SignInUserPassword.tsx +++ b/src/components/Authentication/SignInUserPassword.tsx @@ -63,7 +63,7 @@ const SignInUserPassword = (signInUserProps: SignInUser3Props) => { id, profileImg, firstName, email, } - await setToLocalStorage(storageKeys.USER_PROFILE, JSON.stringify(userProfile)); + await setToLocalStorage(storageKeys.USER_PROFILE, JSON.stringify(userProfile) , true); await setToLocalStorage(storageKeys.USER_EMAIL, data?.data?.email); return { role: role?.orgRole ?? '', diff --git a/src/components/Profile/EditUserProfile.tsx b/src/components/Profile/EditUserProfile.tsx index f83dca1e..66aa9fce 100644 --- a/src/components/Profile/EditUserProfile.tsx +++ b/src/components/Profile/EditUserProfile.tsx @@ -179,7 +179,7 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile }: } updateProfile(userData); - await setToLocalStorage(storageKeys.USER_PROFILE, JSON.stringify(updatedUserData)); + await setToLocalStorage(storageKeys.USER_PROFILE, JSON.stringify(updatedUserData) , true); window.location.reload(); setLoading(false) } diff --git a/src/components/Profile/UserProfile.tsx b/src/components/Profile/UserProfile.tsx index 9f789fc3..398f1427 100644 --- a/src/components/Profile/UserProfile.tsx +++ b/src/components/Profile/UserProfile.tsx @@ -27,7 +27,7 @@ const UserProfile = ({ noBreadcrumb }: { noBreadcrumb?: boolean }) => { const userProfile = { id, profileImg, firstName, email, } - await setToLocalStorage(storageKeys.USER_PROFILE, JSON.stringify(userProfile)) + await setToLocalStorage(storageKeys.USER_PROFILE, JSON.stringify(userProfile) , true) await setToLocalStorage(storageKeys.USER_EMAIL, data?.data?.email) } } catch (error) {