<?php

session_start();

require_once './include/Constants.php';
require_once "./vendor/autoload.php";
require_once "./include/DatabaseConn.php";
require_once "./models/User.php";
require_once './models/Settings.php';


if (isset($_SESSION['gid']) && ($_SESSION['gid'] == true && isset($_SESSION[USER_]))) {
    $db = new DatabaseConn();
    $link = $db->connect();
    $user = unserialize($_SESSION[USER_]);
    User::sendEmailVerification($user, $link);
    $_SESSION[EMAIL] = $user->getEmail();
    unset($_SESSION['gid']);
    unset($_SESSION[USER_]);
    header("location: confirm");
    die();
} else {
    header("location: login");
    die();
}