Created
January 6, 2019 22:13
-
-
Save ProdigyView/c9170ffbe2f8d8d1f7ff5e1eed9a3c98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function checkPrivileges(string $token, string $requested_privilege, array $tokens) : bool { | |
if(!isset($tokens[$token])) { | |
return false; | |
} | |
foreach($tokens[$token]['privileges'] as $privilege) { | |
if($privilege === '*') { | |
return true; | |
} else if($privilege == $requested_privilege) { | |
return true; | |
} | |
return false; | |
}//end foreach | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment