September 2017
Intermediate to advanced
450 pages
11h 24m
English
The jwt-express middleware works very similarly to how our cookie middleware in Express does; the main difference is that the JWT is only written if the user goes through our /login route successfully. Whenever a user makes a request to our application, the JWT is evaluated for whether it's genuine and not yet expired. By setting the JWT token so that it is not sent as a http-only cookie, we can allow Angular to read and parse the token using JwtModule. By parsing the token's contents and using that to set our current user service, we can keep our users logged in via a valid JWT token stored in their browser.
Likewise, deleting the token effectively signs the user out of our application.
Read now
Unlock full access