Skip to content

Instantly share code, notes, and snippets.

@ProdigyView
Created January 6, 2019 22:13
Show Gist options
  • Save ProdigyView/c9170ffbe2f8d8d1f7ff5e1eed9a3c98 to your computer and use it in GitHub Desktop.
Save ProdigyView/c9170ffbe2f8d8d1f7ff5e1eed9a3c98 to your computer and use it in GitHub Desktop.
<?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