Replies: 2 comments
-
Auth checker is only comparing decoded token (user data) against required roles (from decorator). In |
Beta Was this translation helpful? Give feedback.
-
I got around this by moving the logic from context to the auth checker. I think because the JWT verify throws an error when expired you have to validate in the auth checker rather than in the context. Otherwise it doesn't stop execution and continues to the generic 'access denied' error. I think it could be useful to have a comment about it in this example, as that's why I've gotten stuck on the errors for a bit. The try catch isn't completely necessary but lets you add the date to the error message. Without it you'll get
|
Beta Was this translation helpful? Give feedback.
-
I've been reading the docs here again: https://typegraphql.com/docs/authorization.html and can see there is a way to do this with
apollo-server-express
. I'd rather not rewrite everything to use that unless it's completely necessary.I've implemented everything up to getting the refresh token working. To do this, I think I have to be able to return the
TokenExpiredError
which is available in the ApolloServer context:Using this error the frontend apollo client can then know it has to do a token refresh.
Problem is that any auth error is always returned as
Access denied
, so I can't differentiate an expiry and an invalid auth level problem on the frontend.Is there a way to get this error to the frontend without using apollo-server-express?
Beta Was this translation helpful? Give feedback.
All reactions