<?php
// require_once('../../vendor/autoload.php');
require_once('../init.php');

function error_res($status, $response_code, $message)
{
    $response = new stdClass;
    $response->status = $status;
    $response->response_code = $response_code;
    $response->message = $message;
    return json_encode($response);
}
extract($_POST);

if (isset($email) && !empty($email)) {

    $userr = User::find_by_query("SELECT * FROM user WHERE email='$email'");
    $user = array_shift($userr);

    if ($user) {
        include ENVIRONMENT == 'prod' ? '../../email/mail_reset_prod.php' : '../../email/mail_reset_dev.php';
        echo error_res(true, "00", "reset pass link sent");
        exit;
    } else {
        echo error_res(false, "01", "error");
        exit;
    }
} else {

    echo error_res(false, "03", "Registration Error Contact Administrator!");
    exit;
}
