Passing values from middleware to database hooks?

I have a password history checker that I want to fail early in the "Before" middleware. I only have access to the user's email, so I use that to get the user's ID etc. I don't want to have to query again in the "Before Account Update" hook (which only gives me access to the hashed password via account.password). I tried returning in the middleware hook as shown in BA example:
return {
    context: {
        ...ctx,
        body: {
            ...ctx.body,
            userId,
        },
    },
}


but it doesn't remain on the body for the db hooks. What's the BA recommended way to pass values between middleware and db hooks?
Was this page helpful?