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
|
/* [N] Retourne les données
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
return [
|
return [
|
||||||
'actions' => Database::autotype( $sorted_actions ),
|
'actions' => $sorted_actions,
|
||||||
'states' => Database::autotype( $globalStates ),
|
'states' => $globalStates,
|
||||||
'chips' => Database::autotype( $chips ),
|
'chips' => $chips,
|
||||||
'permissions' => Database::autotype( $indexed_permissions )
|
'permissions' => $indexed_permissions
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -363,13 +363,23 @@
|
||||||
for( var a in Object.keys(ACTIONS[COUNT]) ){
|
for( var a in Object.keys(ACTIONS[COUNT]) ){
|
||||||
|
|
||||||
/* (3) On vérifie que l'utilisateur a la permissions d'effectuer l'action */
|
/* (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;
|
var hasPermission = false;
|
||||||
console.log( CARD, PERMISSIONS[CARD], ACTIONS[COUNT][a].id_action, hasPermission);
|
|
||||||
|
|
||||||
// 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;
|
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 */
|
/* (4) Si la condition est correcte, On applique la modification de l'état */
|
||||||
if( previous(ACTIONS[COUNT][a].previous, STATE) ){
|
if( previous(ACTIONS[COUNT][a].previous, STATE) ){
|
||||||
action(ACTIONS[COUNT][a].action, STATE);
|
action(ACTIONS[COUNT][a].action, STATE);
|
||||||
|
|
Loading…
Reference in New Issue