jwt-guard icon indicating copy to clipboard operation
jwt-guard copied to clipboard

Token validation doesn't return the proper cause on response

Open petrenkorf opened this issue 7 years ago • 3 comments

The route in the package is not refreshing valid tokens. How do I procede?

petrenkorf avatar Aug 18 '17 20:08 petrenkorf

Hi @petrisrf do you mean this action? https://github.com/paulvl/jwt-guard/blob/master/src/Foundation/Auth/AuthenticatesUsers.php#L52 are you getting some error or something registered in your log??

paulvl avatar Aug 25 '17 00:08 paulvl

I'm receiving 401 as response, but the token did not expired yet. Is there any prerequisite to refresh a token?

petrenkorf avatar Aug 28 '17 07:08 petrenkorf

Mmm.. as we can see here https://github.com/paulvl/jwt-guard/blob/master/src/Foundation/Auth/AuthenticatesUsers.php#L54 the refresh function validates the token on this function https://github.com/paulvl/jwt-guard/blob/master/src/Auth/JWTGuard.php#L36 the validation in fact must return an absolute "true" value to be valid any other case will cause the refresh function return null and as this condition resolves https://github.com/paulvl/jwt-guard/blob/master/src/Foundation/Auth/AuthenticatesUsers.php#L56 causes a 401 response, but! the validation function gives a reason as you can see here https://github.com/paulvl/jwt-guard/blob/master/src/Auth/JWTGuardTrait.php#L93 so that reason needs to be returned instead of "Unauthorized" error message. I will work on this.

paulvl avatar Sep 01 '17 05:09 paulvl