cd front_end && npm run dev -- --https
cd server && nodemon
cd server && node index.js
Is just a skeleton to create your authentication service with little modifications to the src code.
Good for microservices architecture as it works with JWT.
Scalable database (works with your dynamoDB).
Simple and easy to understand.
Client side
The user throught front-end asks from facebook api to get the access token.
Then when the client agree to give permissions facebook sends the access token to the front end.
After that the front end will send the access token to the backend(server).
Server side
The backend sends the access token to facebook and asks to get data with your codefrom the facebook profile.
And either insert/Fetch user(if already exists) to/from your database.
After that the server will get justInserted or fetched infos user's data to/from the database.
that code may contain data client must not see so you have to modify that data with your code.
After that you sign them and server sends {jwt,user_data,serverErrMsg
modify with your code}
to your client.
Client side
Get that data and inserted to stores {user,failureMsg}
Get {jwt,user} and inserted them on localStorage.
ErrorMessage Component
ErrorMessage Component will show failureMsg
store value for some time (passed through props) or until the component will be destroyed and after that will set failureMsg.set(null)
ErrorMessage doesn't have to be just a string.
But to change the functionallity you have to change both the code on backend(middlewares response : failureMsgData
) as well as the code in the front end"$lib/authentication/ErrorMessage.svelte"
component
UserMiddleware Component
It's used to redirect if user doesn't exist.During reloads of sensitive pages "like profile" it checks to see if token is still valid by hitting "/auth-api/is-verify"
from the server.The server responds and data fetched like thatconst { userData, token, failureMsgData } = parseRes;
failureMsgData
as discussed previously can be changed with server code inside middlewares.Check how we use the code by running and testing the source code in this github repo before you read the documentation. Check the documentation only if you have problems to understanding something.
Error_Message
failureMsg
store for some time if failureMsg!=null
LoginFacebook
UserMiddleware
Checks if user exists and if a page reload has happened it checks that the user is still logged by send "jwt from local storage" to server and verify it.
PROPS:
CAUSION: