0
I have an api on Node and I have the following situation:
I am the master user and create a usuário A
to any employee. That usuário A
has the permissions
Permissions user A
[criar_usuario,editar_usuario,receber_contas,editar_contas,ver_clientes]
So this usuário A
creates another usuário B
in the system with permissions
Permissions user B
[criar_usuario,deletar_usuario,deletar_contas,enviar_sms,excluir_registro]
what I want is to map the permissions of the usuário A
and, if it creates or edits the usuário B
, the usuário B
may have the same permissions as usuário A
or less, but never have permissions that user A does not have.
In the example above, the usuário B
may have:
[criar_usuario,editar_usuario,ver_clientes]
But never:
[deletar_usuario,receber_contas,editar_clientes,ver_clientes]
I tried that
let p = usuarioLogado.permissions; // permissões do usuário logado
let up = req.body.permissoes; // permissões do usuário que será criado ou editado
up.map((o, index) => {
if (p.indexOf(o) <= -1) {
up.splice(index, 1)
}
})
but it doesn’t work, there are traces of the permissions that cannot be applied
fernandosavio, was exactly that. Mto thank you!!!
– Felipe Paz