valid_login_admin.php 1.4 KB
Newer Older
1 2 3 4 5 6
<?php
/* --------------------------------------------------------------------------------------------------------------
 * Copyright (C) 2018 by William Paul Liggett (junktext@junktext.com)
 * This Source Code Form is subject to the terms of the Mozilla Public License (MPL), v. 2.0.
 * If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
 *
7
 * Filename:  validate_login_admin.php
8
 * 
9 10 11
 * Purpose:   Ensure that only administrators can see or change any OpenVigilance Task settings.
 * -------------------------------------------------------------------------------------------------------------- */

12
$valid_login_admin = false;
13 14

// Sets the `$ov_admin_username' and the `$ov_admin_password_hash' variables.
15
require_once "../../../../protected_site_configs/openvigilance_admin_account.php";
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

// The `$submitted_username' and `$submitted_password' variables are from the calling PHP script.
// Also, the `$error_msg' is a standardized variable in all calling scripts to output the login error found.

// Determines if the login was valid or not.
if($submitted_username !== $ov_admin_username) {
    $error_msg = "Error: The username is not valid on this system.";
    return;
}

else if(!password_verify($submitted_password, $ov_admin_password_hash)) {
    $error_msg = "Error: The password is incorrect.";
    return;
}

// Valid login!
else {
33
    $valid_login_admin = true;
34
}