Hello , i am trying to implement an RBAC feature.
My approach is,
- I ll create a Content Type , called RBAC where i 'll store user_id, conent_type and action type. (that the user can perform)
- Create a global middleware where it calls the RBAC contenttype and appends to the ctx the rbac information.
- Create policies to each route accordingly.
I`ve created my global middleware. registered in the /config/middleware.js. (at the end)
Issue:
I cannot access the current user (if it exists) in the middleware.
ctx.state.user = {} but in the controller i have that information.
Any suggestions how i can tackle this? It would be wiser for me if can someone provide me with a Request Life Cycle, so i will know in the future, where for example, the user gets appended in the ctx (and by what) . With this i think will help me (and other devs) solve issues on our own
Thank you in advance