Commit 024efa2b authored by sandroresende's avatar sandroresende

alteracao AuthService

parent 0771caab
<?php
namespace App\Providers;
use Illuminate\Auth\Notifications\ResetPassword;
use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Notifications\Messages\MailMessage;
class AuthServiceProvider extends ServiceProvider
{
/**
* The password reset token.
*
* @var string
*/
public $token;
/**
* The callback that should be used to build the mail message.
*
* @var \Closure|null
*/
public static $toMailCallback;
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
'App\Model' => 'App\Policies\ModelPolicy',
];
/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
$this->registerPolicies();
Gate::define('eAdmin', function ($user) {
return $user->tipo_usuario_id == 1;
});
Gate::define('eConsulta', function ($user) {
$tipoUsuario = [1,2,3,4,5,6];
if(in_array($user->tipo_usuario_id, $tipoUsuario)){
return true;
}
return false;
});
Gate::define('eGestao', function ($user) {
if(($user->tipo_usuario_id == 1) || ($user->tipo_usuario_id == 6)){
return true;
}
return false;
});
Gate::define('eSaci', function ($user) {
if(($user->tipo_usuario_id == 1) || ($user->tipo_usuario_id == 12)){
return true;
}
return false;
});
ResetPassword::toMailUsing( function($notifiable) {
if (static::$toMailCallback) {
return call_user_func(static::$toMailCallback, $notifiable, $this->token);
}
return (new MailMessage)
->subject('Notificação de resete de Senha')
->line('Você está recebendo este e-mail porque recebemos uma solicitação de redefinição de senha para sua conta.')
->action('Resetar senha', url(config('app.url').route('password.reset', $this->token, false)))
->line('Se você não solicitou uma redefinição de senha, nenhuma outra ação será necessária.');
});
}
}
......@@ -30,6 +30,13 @@ class AuthServiceProvider extends ServiceProvider
return $user->tipo_usuario_id == 1;
});
Gate::define('eGestao', function ($user) {
if(($user->tipo_usuario_id == 1) || ($user->tipo_usuario_id == 6)){
return true;
}
return false;
});
Gate::define('eConsulta', function ($user) {
$tipoUsuario = [1,2,3,4,5,6];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment