Friday 27 December 2019

Advice on mern authentication application

I am building a full stack application using the mern stack. This application is required to allow users to register and login and once they are logged in the users should be able to view and add information to their profile only. My backend is working great and i am using jwt to check who is logged in and then that allows me to post as that user only which is great.In my front end though i am able to login and sign up as specific users and it connects to the backend well, the only issue/question i am having here is when the users login they should be able to create their own car data so every car will have their own user assigned to it( in my backend i connected both user and car schema well and every car has an id) that is how i know who owns what car.My question is i want to fetch all the cars from the database and display them ( thinking this would work well but have not done it this way) vs having an additional localstorage item which then contains the token of the logged in user and another one that will contain the logged in users newly created cars ( this request gets sent to the back end either way and creates a new car from my backend end point ) i am using local storage here to keep track of the current users cars.What is the best way i can link the current users newly created car because right now local storages like a good approach.Thank you in advance

Submitted December 27, 2019 at 08:38AM by giordi12

No comments:

Post a Comment