<?php
namespace nur\v\vp;

use nur\authz;
use nur\config;
use nur\cookie;
use nur\F;
use nur\v\page;

class AppLogoutPage extends AInitPage {
  /** @var bool faut-il désactiver la redirection vers mainUrl? */
  const DEBUG = false;

  function isDebug(): bool {
    if (!config::is_devel()) return false;
    return static::DEBUG || F::get("d");
  }

  function setup(): void {
    cookie::set("MOD_AUTH_CAS", false);
    cookie::set("MOD_AUTH_CAS_S", false);
    authz::manager()->resetSession(authz::DISCONNECTED);
    if (!$this->isDebug()) page::redirect($this->getMainUrl());
  }

  function print(): void {
    echo "logout\n";
  }
}