lundi 16 septembre 2019

How to stop users access a page directly from url in laravel

I am using laravel5.8 package laravel-permission. If a login user know any url, he can access directly from browser.

I am using below code to generate menu

@role('HR')
  //show menu links of HR
@endrole

Now Users with HR roles will see only his links. But he can also access other pages by url directly.

I know i can stop by either below ways

public function __construct()
{
  $this->middleware(['role_or_permission:Admin|HR|HRM']);
}
OR
Route::group(['middleware' => ['role_or_permission:HR|edit articles']], 

What if any new role & permission is created which is not mentioned above?

I want one single function/code with stop users to access different role/permission area.

How can i do it?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire