Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission role guest #44

Open
goldwizard13 opened this issue Feb 2, 2022 · 0 comments
Open

Permission role guest #44

goldwizard13 opened this issue Feb 2, 2022 · 0 comments

Comments

@goldwizard13
Copy link

goldwizard13 commented Feb 2, 2022

Add access to the site to guests, did as below, but writes an error in the logs
TodoController

public function initialize()
 {
     $this->loadComponents([
         'Auth' => [
         'authorize'    => ['Controller']
         ],
        'Security'
   ]);
}
  public function isAuthorized()
     {
          $action = $this->request->param('action');
         $role = (!empty(Session::getUserRole()) ? Session::getUserRole() : 'guest');
          $resource = "todo";
         // only for admins
         Permission::allow('admin', $resource, ['*']);
        // only for normal users
         Permission::allow('guest', $resource, ['index','getList']);
         // only for normal users
        Permission::allow('user', $resource, ['index','getList', 'create']);
         Permission::allow('user', $resource, ['getMain'], 'owner');
 }

writes in logs (not always): guest is not allowed to perform getmain action on todo (

Logger::log("Permission", $role . " is not allowed to perform '" . $action . "' action on " . $resource, __FILE__, __LINE__);
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant