<?php

namespace App\Http\Controllers\Peertube;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Peertube\Common;
// use Illuminate\Support\Facades\Log;

class Logout extends Common {
  private $common;

  public function __construct () {
    $this->common = new Common;
  }

  public function logout () {
    $this->ptapi('/api/v1/users/revoke-token', '', 'post');
    unset($_COOKIE['access_token']);
    unset($_COOKIE['refresh_token']);
    setcookie('access_token', '', time() - 3600, '/', $_SERVER['HTTP_HOST'], 0, 1);
    setcookie('refresh_token', '', time() - 3600, '/', $_SERVER['HTTP_HOST'], 0, 1);

    return redirect('/peertube/home');
  }
}
