mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 19:04:52 +00:00
Move role validation to functions.php
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user