search

Home  >  Q&A  >  body text

laravel - routing permissions issue

Route::group(['middleware' => 'privilege_auth:' . Privilege::Agent . ',true'], function () {
    Route::get('/agent', function () {
        return View::make('agent/agent')->with(["resource_host"=>env("STATIC_RESOURCE_HOST")]);
    });
    Route::get('/admin/{theme}/page', 'AdminController@getEditPage');
});

Route::group(['middleware' => 'privilege_auth:' . Privilege::Agent . ',true'], function () {
    Route::get('/agent', function () {
        return View::make('agent/agent')->with(["resource_host"=>env("STATIC_RESOURCE_HOST")]);
    });
    Route::get('/admin/{theme}/page', 'AgentController@getEditPage');
});

The Agentservice corresponding to AgentController inherits from the Adminservice corresponding to AdminController, and some permissions are restricted in AgentService. However, I later discovered that after writing the route like this, if I log in with an account with admin permissions, it will eventually become agent permissions. Is there any solution? ?

伊谢尔伦伊谢尔伦2791 days ago403

reply all(1)I'll reply

  • ringa_lee

    ringa_lee2017-05-16 16:50:33

    These two routing groups cannot be used together because the routing rules are the same. Laravel will use the second routing to overwrite the first one, so no matter how they are used, the second group is valid. If they must be used together, The routing prefix prefix should be added to the group to distinguish it.

    reply
    0
  • Cancelreply