import { getdataUser} from "../hooks/validateJwt"; export const tokenValidator = async (token: string) => { var jwtDecode = require('jwt-decode'); const decoded = jwtDecode(token); const exp = decoded.exp; const expirationDate = new Date(exp*1000); const currentDate = new Date(); try{ const tokenValid = await getdataUser(token); if (expirationDate < currentDate && !tokenValid.hasOwnProperty["data"]) { return false; } else { return tokenValid; } } catch (error) { console.log(error) return false; } }