Ejemplo n.º 1
0
 public static function isTokenExpired($token)
 {
     $user = User::where('token', $token)->first();
     $token_expire = $user['token_expire'];
     $currTime = date('Y-m-d H:i:s');
     if ($token_expire < $currTime) {
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 2
0
 /**
  * @param Slim $app
  * @return $response
  */
 public static function logout(Slim $app)
 {
     $response = $app->response();
     $response->headers->set('Content-Type', 'application/json');
     $username = $app->request->params('username');
     $password = $app->request->params('password');
     $credentials = self::validateCredentials($app, $username, $password);
     if ($credentials) {
         User::where('username', $username)->update(['token' => null, 'token_expire' => null]);
         $response->body(json_encode(['status' => 200, 'message' => 'session destroyed success!']));
         return $response;
     }
 }