slim-jwt-auth icon indicating copy to clipboard operation
slim-jwt-auth copied to clipboard

Calling response object from "before" callback

Open geshub opened this issue 5 years ago • 3 comments

I'm using version 3.4 and I'm running some checks based on the decoded token in the "before" callback just after the token has been validated. The problem is that if one of the check fails, I can't return a 401 from the callback as I can't access the response object. I've seen it was possible in the previous version. Is there any way I can call the error callback from "before", halt the execution or do I need to do my checks in another middleware called after the token is validated ?

geshub avatar Jun 28 '20 11:06 geshub

maybe you should use 'after' instead. it is intended to run after jwt checking done

malaDev avatar Nov 30 '20 05:11 malaDev

'before' is also after the JWT checking. The possible problem is that other middleware have run then as well which may not be desired.

markoheijnen avatar Feb 17 '21 14:02 markoheijnen

@geshub have you managed to solve that problem, do I have the same situation?

LeonardoYoel avatar Jul 05 '21 20:07 LeonardoYoel