LakshmiSowmya04 / Task-Manager

simple task management application built using the MERN stack
15 stars 36 forks source link

[Bug]: Integrate front end and backend and Make data pass to backend #62

Closed vishal-kumar3 closed 1 month ago

vishal-kumar3 commented 1 month ago

created postman api docs and fixed few error handling and fixed the middleware Postman file is included inside the backend folder. Postman api docs link:- https://task-manager-7662.postman.co/workspace/New-Team-Workspace~6e258579-f214-4bf5-8387-9f9a725b6be3/collection/32491304-282dba7a-9266-4ec3-92f4-becce83cbc65?action=share&creator=32491304

vishal-kumar3 commented 1 month ago

hey @LakshmiSowmya04, i have fixed the login bug too.

LakshmiSowmya04 commented 1 month ago

@vishal-kumar3 great work vishal ...thank you

LakshmiSowmya04 commented 1 month ago

@vishal-kumar3 ...but i am unable to do sign up

image

LakshmiSowmya04 commented 1 month ago

login is also not happening .....

vishal-kumar3 commented 1 month ago

@LakshmiSowmya04, i thought you said that don't do the fronend, so i just created the api docs and fixed few bugs in backend only. Do you want me to fix the fronend part?

LakshmiSowmya04 commented 1 month ago

@LakshmiSowmya04, i thought you said that don't do the fronend, so i just created the api docs and fixed few bugs in backend only. Do you want me to fix the fronend part?

even after sign up its not logging in

vishal-kumar3 commented 1 month ago

@LakshmiSowmya04, i thought you said that don't do the fronend, so i just created the api docs and fixed few bugs in backend only. Do you want me to fix the fronend part?

even after sign up its not logging in

let me see whats the problem

LakshmiSowmya04 commented 1 month ago

@LakshmiSowmya04, i thought you said that don't do the fronend, so i just created the api docs and fixed few bugs in backend only. Do you want me to fix the fronend part?

even after sign up its not logging in

let me see whats the problem

Problem is even after signing in it is again showing warning to sign in

vishal-kumar3 commented 1 month ago

@LakshmiSowmya04 , the cookie is not handled correctly in the frontend, that's why is happening. Need to fix the fronend and also i will create api to get the current user or logged in user.

LakshmiSowmya04 commented 1 month ago

@LakshmiSowmya04 , the cookie is not handled correctly in the frontend, that's why is happening. Need to fix the fronend and also i will create api to get the current user or logged in user.

Close this and open new one so I will assign under hacktoberfest to u

LakshmiSowmya04 commented 1 month ago

@LakshmiSowmya04 , the cookie is not handled correctly in the frontend, that's why is happening. Need to fix the fronend and also i will create api to get the current user or logged in user.

Can I ask why ??...here they are storing token when generated in local storage and passing to login component and if login is true it passes to dashboard right?

vishal-kumar3 commented 1 month ago

@LakshmiSowmya04, this is because you are storing the token using useState and according to the code :-

useEffect(() => {
    const token = localStorage.getItem("token");
    if (token) {
      setToken(token);
    }
  }, []);

it appears that token is getting stored into the local storage but in reality this useEffect is triggered only once since it only runs when component is mounted. Rather it should have dependency 'token', and then when ever token is updated, it will run again and also update the local storage.

LakshmiSowmya04 commented 1 month ago

@LakshmiSowmya04, this is because you are storing the token using useState and according to the code :-

useEffect(() => {
    const token = localStorage.getItem("token");
    if (token) {
      setToken(token);
    }
  }, []);

it appears that token is getting stored into the local storage but in reality this useEffect is triggered only once since it only runs when component is mounted. Rather it should have dependency 'token', and then when ever token is updated, it will run again and also update the local storage.

Yeahh you are right!

vishal-kumar3 commented 1 month ago

@LakshmiSowmya04, And you should use redux for state management so that you can use this token in every page to know if user is loggedin. Or may be you can setup a backend api for getting the user data of logged in user. And token should not be stored in local storage since you have less control over it that is if token expires, it will not be deleted automatically. so you must think of storing this token in the cookie storage.

LakshmiSowmya04 commented 1 month ago

Yeah...if you can implement this please raise a PR or for now keep token in dependency array

On Thu, Oct 3, 2024, 11:23 Vishal Kumar @.***> wrote:

@LakshmiSowmya04 https://github.com/LakshmiSowmya04, And you should use redux for state management so that you can use this token in every page to know if user is loggedin. Or may be you can setup a backend api for getting the user data of logged in user. And token should not be stored in local storage since you have less control over it that is if token expires, it will not be deleted automatically. so you must think of storing this token in the cookie storage.

— Reply to this email directly, view it on GitHub https://github.com/LakshmiSowmya04/Task-Manager/pull/62#issuecomment-2390580459, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2XMWL5TX7KVV7I5C4LEI73ZZTLWVAVCNFSM6AAAAABPIDOKHWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOJQGU4DANBVHE . You are receiving this because you were mentioned.Message ID: @.***>

vishal-kumar3 commented 1 month ago

@LakshmiSowmya04, i don't think i should change anything now since many contributors are working on this and changing the base authentication thing can break everything and then you will have to change/tweak many things.

LakshmiSowmya04 commented 1 month ago

Even if we don't change anything it will lead the same issues...it's fine I will look into it

On Thu, Oct 3, 2024, 12:12 Vishal Kumar @.***> wrote:

@LakshmiSowmya04 https://github.com/LakshmiSowmya04, i don't think i should change anything now since many contributors are working on this and changing the base authentication thing can break everything and then you will have to change/tweak many things.

— Reply to this email directly, view it on GitHub https://github.com/LakshmiSowmya04/Task-Manager/pull/62#issuecomment-2390641744, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2XMWL3UCKKZYLGFO65TECLZZTRNLAVCNFSM6AAAAABPIDOKHWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOJQGY2DCNZUGQ . You are receiving this because you were mentioned.Message ID: @.***>