Skip to content

Commit

Permalink
added logs in display user profile
Browse files Browse the repository at this point in the history
  • Loading branch information
bhavanakarwade committed Dec 4, 2024
1 parent 20aa8a5 commit 248edfb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions src/api/Auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/Profile/DisplayProfileImg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { storageKeys } from "../../config/CommonConstant.ts";
const DisplayProfileImg = () => {
const [userObj, setUserObj] = useState<IUserProfile | null>(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......................................')
Expand Down
2 changes: 1 addition & 1 deletion src/components/Profile/DisplayUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 248edfb

Please sign in to comment.