diff --git a/src/api/Auth.ts b/src/api/Auth.ts index 93e5dfb6..f9318c5b 100644 --- a/src/api/Auth.ts +++ b/src/api/Auth.ts @@ -242,12 +242,13 @@ export const encryptData = (value: any): string => { } } -export const decryptData = (value: any): string => { +export const decryptData = (value: any , isUserProfile?: boolean): string => { const CRYPTO_PRIVATE_KEY: string = `${envConfig.PUBLIC_CRYPTO_PRIVATE_KEY}` try { let bytes = CryptoJS.AES.decrypt(value, CRYPTO_PRIVATE_KEY); - console.log(bytes , 'bytes........................') + if(isUserProfile){ + console.log(bytes , 'bytes........................')} return bytes.toString(CryptoJS.enc.Utf8); } catch (error) { // Handle decryption error or invalid input @@ -272,10 +273,11 @@ export const setToLocalStorage = async (key: string, value: any) =>{ return true } -export const getFromLocalStorage = async (key: string) =>{ +export const getFromLocalStorage = async (key: string , isUserProfile?: boolean) =>{ const value = await localStorage.getItem(key) - console.log(value , 'local storage value ............................') - const convertedValue = value ? await decryptData(value) : '' + if(isUserProfile){ + console.log(value , 'local storage value ............................')} + const convertedValue = value ? await decryptData(value ,isUserProfile ) : '' return convertedValue } diff --git a/src/components/Profile/DisplayProfileImg.tsx b/src/components/Profile/DisplayProfileImg.tsx index ad9fbcce..2c4b9c2e 100644 --- a/src/components/Profile/DisplayProfileImg.tsx +++ b/src/components/Profile/DisplayProfileImg.tsx @@ -8,7 +8,7 @@ import { storageKeys } from "../../config/CommonConstant.ts"; const DisplayProfileImg = () => { const [userObj, setUserObj] = useState(null) const getUserDetails = async () => { - const userProfile = await getFromLocalStorage(storageKeys.USER_PROFILE) + const userProfile = await getFromLocalStorage(storageKeys.USER_PROFILE , true) const orgRoles = await getFromLocalStorage(storageKeys.ORG_ROLES) const parsedUser = userProfile ? JSON.parse(userProfile) : null; console.log(parsedUser, 'in display profile image......................................') diff --git a/src/components/Profile/DisplayUser.tsx b/src/components/Profile/DisplayUser.tsx index 9d184889..ad0b7d79 100644 --- a/src/components/Profile/DisplayUser.tsx +++ b/src/components/Profile/DisplayUser.tsx @@ -11,7 +11,7 @@ const DisplayUser = () => { let timer:any= null const getUserDetails = async () => { - const userProfile = await getFromLocalStorage(storageKeys.USER_PROFILE) + const userProfile = await getFromLocalStorage(storageKeys.USER_PROFILE , true) const orgRoles = await getFromLocalStorage(storageKeys.ORG_ROLES) const parsedUser = userProfile ? JSON.parse(userProfile) : null console.log("in display user .....................", parsedUser)