Client Virtuel: Gestion des permissions opérationnel, mais à tester en profondeur
This commit is contained in:
parent
7c3d79e4ec
commit
6011199fc7
|
@ -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
|
||||
];
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue