This assignment involves setting up a simple username/password authentication system using Redux for state management and Next.js for the front-end and back-end. You will create API endpoints with bearer token authentication and implement a custom useAuthSession hook to manage the user's session on the client side.
-
Implement the
useAuthSessionHook:- In
hooks/useAuthSession.ts, create a custom hook that manages the user's authentication session. - The hook should handle checking if a user is authenticated and fetching user data.
- In
-
Create and Complete the API Endpoints:
- Created the required User and Login Endpoint
-
Bearer Token Authentication:
- Implemented bearer token authentication in your API endpoints.
- Ensured that API requests are secured and only accessible to authenticated users.
-
Added Proper Form Validation using React-hook-form
-
Added toast UI component from shadcn for Erros and Successdul Logins
const { user } = useAuthSession();
if (user) {
console.log('User:', user.username);
} npm install
npm run dev