mwangimuringi / zurihomes

Kahawa yetu is a kenya coffee cooperative system.
https://zurihomes.vercel.app
2 stars 1 forks source link

Backend - Implement User Signout API. #101

Closed mwangimuringi closed 3 days ago

mwangimuringi commented 3 days ago

The user signout functionality is currently missing in the backend. A new API endpoint is needed to handle user signout by clearing the authentication token stored in cookies. Acceptance Criteria:

A POST /api/users/signout endpoint should be implemented.
The endpoint should clear the authToken cookie.
The endpoint should return a 200 status code with a success message upon successful signout.

Tasks:

Add a signout route to the user.route.js file. Use res.clearCookie() to remove the authentication cookie. Return an appropriate success response.

muringitech commented 3 days ago

Why use a POST method instead of GET? A POST method is more appropriate for actions that change the server state or involve user data, such as signing out. It prevents unintentional signout from being triggered by clicking a link.

muringitech commented 3 days ago

How does this work with tokens stored in HTTP headers? For JWT tokens stored in headers, additional backend logic may be required to blacklist or invalidate tokens.