<?php
if(!defined('APPLICATION_VERSION')){
    die("Permission denied!");
}

if($user->isLoggedIn()){
    header('Location:dashboards');
}

if(isset($_REQUEST['generate']) && $_REQUEST['generate'] === 'newToken') {
    include('templates/ForgotPasswordForm.php');
} else if(isset($_REQUEST['token'])) {
    $confirmTokenMessage = $user->checkPasswordToken($_REQUEST['token']);
    if($confirmTokenMessage === 'success') {
        include('templates/ResetPasswordForm.php');
    } else {
        echo '<div id="confirmation-message" class="col-sm-4 col-sm-offset-4 password-confirmation-messages alert alert-danger">';
            echo '<span class="glyphicon glyphicon-alert"></span> {{"validation.messages.INVALID_TOKEN" | translate}}';
        echo '</div>';
        echo '<div id="back-to-sign-in" class="col-sm-4 col-sm-offset-4 back-to-sign-in-btn alert alert-info">';
            echo '<a href="login">{{"validation.buttons.SIGN_IN" | translate}}</a>';
        echo '</div>';
    }
} else {
    include('templates/LoginForm.php');
}
