Please enable JavaScript.
Coggle requires JavaScript to display documents.
Client (Server (Model (Schema, Schema methods), Controller…
Client
Server
Model
Schema
Schema methods
Controller
Authentication
Database
Routes
Passport Service
Passport Strategies
JWT Strategy
Extract Token from request header & use secret
Decode payload and find user by decoded id
Make passport use this strategy
Local Strategy
Extracts the user email and password if Email is supplied
Checks to see if the passwords match using Schema method on user
Find user by email and compare password.
return user
localhost:3000
Separate Web Server
React - Redux
localhost:8080
Auth Functionality
SignIn
SignUp
App Functionality
User Profile
All Books
Adding Books
Lending Books
SignUp
/signup route
Using Controller for signup - Model (check database)
Error response
Save to database
Create Token & Send Token back
Protected Route
/
Use Passport JWT Strategy to pass request through
If returns user ? send response back
If error ? send 'Unauthorised' back
Controller response
SignIn
/signin route
Use Passport Local Strategy to pass request through
Using Controller for signin
Get returned user from passport strategy on password compare.
Create a new token for that user and send back token.