/** * Validate token * * @param Slim $app * @return bool */ public static function validateToken(Slim $app) { Setup::setTimezone(); $user = Setup::getUserWithToken($app); $tokenExpire = $user->getRecord()['dbData']['token_expire']; $timeNow = new DateTime(); $expiryTime = new DateTime($tokenExpire); if ($timeNow->getTimestamp() < $expiryTime->getTimestamp()) { return true; } else { Setup::unsetToken($user); $app->response->headers->set('Content-Type', 'application/json'); $app->halt(401, json_encode(['message' => 'Expired Token'])); } }