Technologies
- node
- express
- passport
Problem
I have a middleware (passport-azure-ad) which authenticates the user and then adds the user and his permissions to the request object.
In my Express RequestHandler
s, when trying to access that user, it says, that the field does not exist on the type. How to solve this issue?
What I tried
I tried extending express like this:
declare global {
namespace Express {
interface Request {
user?: AuthenticatedUser
}
}
}
But somehow it didn’t properly pick up the “AuthenticatedUser” type and therefore I still couldn’t access the users properties.