In this lesson, we will build a token issuer that will return a JSON Web Token. This simple server will have a single endpoint for login that queries a list of users and returns a web token for the matching user.
Why are you validating the passwords match? Why does that matter?
I here, we validate that the user provided password matches the user password on the server database. This way, we are authenticating the user. Without a valid password, we are not serving a JWT so he can't login.
What does sub
mean where we sign the jwt?
sub
stands for subject
. Basically, it tells the JWT consumer "who/what this token is about". In most cases, it represents the user id.