Client Virtuel: Gestion des permissions opérationnel, mais à tester en profondeur

This commit is contained in:
xdrm-brackets 2016-07-19 19:04:17 +02:00
parent 8bd3ab4736
commit b4023e83a1
2 changed files with 17 additions and 7 deletions

View File

@ -453,10 +453,10 @@
/* [N] Retourne les données
=========================================================*/
return [
'actions' => Database::autotype( $sorted_actions ),
'states' => Database::autotype( $globalStates ),
'chips' => Database::autotype( $chips ),
'permissions' => Database::autotype( $indexed_permissions )
'actions' => $sorted_actions,
'states' => $globalStates,
'chips' => $chips,
'permissions' => $indexed_permissions
];
}

View File

@ -363,13 +363,23 @@
for( var a in Object.keys(ACTIONS[COUNT]) ){
/* (3) On vérifie que l'utilisateur a la permissions d'effectuer l'action */
var hasPermission = PERMISSIONS.hasOwnProperty(CARD) && PERMISSIONS[CARD].indexOf(ACTIONS[COUNT][a].id_action) > -1;
console.log( CARD, PERMISSIONS[CARD], ACTIONS[COUNT][a].id_action, hasPermission);
var hasPermission = false;
// Si pas la permission, on fait rien
// On vérifie parmis toutes les permissions de cette CARTE
if( PERMISSIONS.hasOwnProperty(CARD) )
for( var i = 0 ; i < PERMISSIONS[CARD].length ; i++ )
if( PERMISSIONS[CARD][i] == ACTIONS[COUNT][a].id_action ){
hasPermission = true;
break;
}
// Si on a pas la permission, on quitte
if( !hasPermission ) continue;
// Si pas la permission, on fait rien
if( !hasPermission ) break;
/* (4) Si la condition est correcte, On applique la modification de l'état */
if( previous(ACTIONS[COUNT][a].previous, STATE) ){
action(ACTIONS[COUNT][a].action, STATE);