hasib32 / rest-api-with-lumen

Rest API boilerplate for Lumen micro-framework.
486 stars 144 forks source link

[NEED HELP] "Insufficient privileges to perform this action", other than users:list #58

Closed handhikadj closed 6 years ago

handhikadj commented 6 years ago

I've got the response ("Insufficient privileges to perform this action") towards the api_token when try to register or login. i don't know what went wrong register method: https://pastebin.com/Wn2YVTKs login method: https://pastebin.com/bCDScg7B I've had:

  1. migrate and seed
  2. passport:install
  3. register or login and accessing UserController@show,update,destroy by passing the retrieved token
  4. An example accessing UserController@show, got error: apierror

Note: UserController@store hasn't tested yet

Update: when I comment the this->authorize() for each given methods, it works. means there's something wrong in the policy. what should I do next?

hasib32 commented 6 years ago

Look at this documentation. https://laravel.com/docs/5.6/authorization#writing-policies Your current authenticated user trying to see other user information. By default a basic user can't see other user information. Need to create a admin user to see other user information.

handhikadj commented 6 years ago

so, it needs to be Admin right? In the default migration, there is role field which I think defines the authorization. The default role is Basic and I can't see the Admin policy created for that

reorg-hhasibul commented 6 years ago

Yeah, there is no migration for that. For now, you can manually set in database.

handhikadj commented 6 years ago

@reorg-hhasibul : no, I pointed out the policy for Admin. there's no Admin policy created in this package. so we can do nothing, other than index and store methods

reorg-hhasibul commented 6 years ago

https://github.com/hasib32/rest-api-with-lumen/blob/master/app/Policies/UserPolicy.php#L16-L22

handhikadj commented 6 years ago

@reorg-hhasibul : Thank you so much. I don't see there's isAdmin method. Thank you again

reorg-hhasibul commented 6 years ago

No problem. Wish you good luck.

handhikadj commented 6 years ago

Closed #58