From 5a76ef9070905c03cc05ac54a9dc46f464749d8f Mon Sep 17 00:00:00 2001 From: Facundo Inza Date: Tue, 3 Oct 2023 14:53:33 -0400 Subject: [PATCH] fix: Debug production --- .eslintrc.json | 3 +-- adapters/userAdapters.ts | 4 ++++ utils/token.ts | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 640ba29..11f1812 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -56,8 +56,7 @@ "@typescript-eslint/no-explicit-any": "off", "jsdoc/require-param-type": "off", "jsdoc/require-returns-type": "off", - "prettier/prettier": "warn", - "no-console": "error" // Agrega la regla para prohibir console.log en archivos JS + "prettier/prettier": "warn" } } ] diff --git a/adapters/userAdapters.ts b/adapters/userAdapters.ts index edf2743..55f5000 100644 --- a/adapters/userAdapters.ts +++ b/adapters/userAdapters.ts @@ -44,8 +44,12 @@ function isValidUser(user: any): user is IUser { export async function getUserFromServer(): Promise { const token = cookies().get('token'); + console.log('token -> getuserfromserver', token); + const payload = await validateToken(token?.value as string); + console.log('payload -> getUserFromSever', payload); + if (!payload || !isValidUser(payload.user)) { return userEmpty; } diff --git a/utils/token.ts b/utils/token.ts index ec61516..649be9b 100644 --- a/utils/token.ts +++ b/utils/token.ts @@ -10,8 +10,11 @@ export const validateToken = async (token: string) => { algorithms: ['HS256'], // Specify the algorithm you are using }); + console.log('payload -> validateToken', payload); + return payload; } catch (error) { + console.error('Error al validar el token:', error); return null; } };