Skip to content

Commit

Permalink
fix issue uspdev#74
Browse files Browse the repository at this point in the history
Contorna o problema de não haver informação de monitores no replicado subordinando o gate às variáveis de ambiente REPLICADO_MONITORES e MONITORES
  • Loading branch information
wgnann committed Jun 29, 2023
1 parent 0d6efd7 commit ddd9b42
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,9 @@ CUPS_SERVER_IP=192.168.8.43
PRINTING_DRIVER=cups
CUPS_SERVER_USERNAME=root
CUPS_SERVER_PASSWORD=123

#Ativa o uso do replicado para obter os monitores (default: true)
#REPLICADO_MONITORES=true

#Lista os monitores caso REPLICADO_MONITORES=false (default: vazio)
#MONITORES=
5 changes: 4 additions & 1 deletion app/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ public function boot()
Gate::define('monitor', function ($user) {
if(Gate::allows('admin')) return True;

$monitores = ReplicadoTemp::listarMonitores(22);
if (!env('REPLICADO_MONITORES', true))
$monitores = explode(',', env('MONITORES', ''));
else
$monitores = ReplicadoTemp::listarMonitores(22);

return in_array($user->codpes, $monitores);
});
Expand Down

0 comments on commit ddd9b42

Please sign in to comment.