<?php
/**
 *  Copyright (C) 2021  Double Bastion LLC
 *
 *  This file is part of Roundpin, which is licensed under the
 *  GNU Affero General Public License Version 3.0. The license terms
 *  are detailed in the "LICENSE.txt" file located in the root directory.
 */

session_start();

if (isset($_POST['s_ajax_call']) && ($_POST['s_ajax_call'] == $_SESSION['validate_s_access'])) {

 define('ACCESSCONST', TRUE);

 require('db-connect.php');

    $username = $_POST['username'];

    // Close Roundpin user account
    $closeacquery = $mysqli->query("UPDATE app_users SET enabled = 0 WHERE username = '$username'");

    if ($closeacquery) {
        $closeaccountmessage = "Your Roundpin user account has been closed successfully!";
    } else { $closeaccountmessage = "An error occurred while attempting to close your user account! Please talk to the system administrator about this issue."; }

    echo json_encode($closeaccountmessage);

} else {
     header("Location: roundpin-login.php");
}

?>
