Passing a variable to middleware #3907
Unanswered
dmeinke-etc
asked this question in
Help
Replies: 1 comment
-
Hi @dmeinke-etc , Check this out, it is probably exactly what you need: e.g. import Route from '@ioc:Adonis/Core/Route'
import Post from 'App/Models/Client'
Route.get('client/:id', async ({ bouncer, request }) => {
const client= await Client.findOrFail(request.param('id'))
await bouncer.authorize('viewClient', client)
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I want to ensure a user has access to the client page they are attempting to reach with the
Route.get('/client/:id', 'ClientController.index').middleware('clientAccess')
But I want to make sure the :id is something the user has access too.
I have an array of ID's in a session called user_access. In the middleware handle function I want to test if it is true
But how do I pass the :id to the middleware?
Beta Was this translation helpful? Give feedback.
All reactions