It goes like this, I make a log in request to the server. If the log in attempt is successful, it sends back a web token to the client side.
It then saves the web token in the local storage for future usage.
However, I need to get the ID of the user that logged in and save it for future usage, which is encrypted in the Hash code that I received.
In the server side Java, I can do something like:
int id = (int) Jwts.parser().setSigningKey(gm.getKey()).parseClaimsJws(token).getBody().get("id_user");
but I need it in the Client side, and with Javascript.
Does anyone have an idea of how to do this?
I've thought of 2 work arounds, but I'm sure there's an easier and faster way of doing it.
A) I could make a separate POST request to the server in which I send the web token I just received which then returns the id of the user.
B) I could also make an "Auth" class that has a String hash_code and an int id_user, then send back an Object of that Auth class as a Json and work from there.
Anyway, thanks.