<?php 

require __DIR__ . '/init.php';

isset($_POST['email']) or DIE;


// Get the user associated to the email!

$user = dashboard::fetch_assoc( DB_TABLE_PREFIX . "_users", $_POST['email'], 'email' );

if( !$user ) uss::stop( false, "No account is associated to the email" );


// Check if the email has already been verified!

$vcode = uss::$global['usermeta']->get('v-code', $user['id']);

if( !$vcode ) uss::stop( false, "The email address has already been confirmed" );


// Resend The confirmation email!

$sent = dashboard::call('email:confirm_user_email', $user['email'] );

$message = $sent ? 'Please confirm the link sent to your email' : 'Sorry! email confirmation link could not be sent';


// Inform the client;

uss::stop( $sent, $message );
