Move role validation to functions.php

This commit is contained in:
Marcus Hill
2022-05-07 17:25:30 +01:00
parent d900a7d341
commit 5cbd0fad0d
4 changed files with 124 additions and 525 deletions

View File

@@ -1,5 +1,8 @@
<?php
// Role check failed wording
DEFINE("WORDING_ROLECHECK_FAILED", "You are not permitted to do that!");
function keygen()
{
$chars = "abcdefghijklmnopqrstuvwxyz";
@@ -432,4 +435,38 @@ function validateCSRFToken($token){
}
}
/*
* Role validation
* Admin - 3
* Tech - 2
* Accountant - 1
*/
function validateAdminRole(){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
$_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
}
function validateTechRole(){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
$_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
}
function validateAccountantRole(){
if($session_user_role == 2){
$_SESSION['alert_type'] = "danger";
$_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
}
?>