Signing in to Ad Management System requires an email address and password that match an existing record in MongoDB. When the credentials are verified, the ZustandDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Priyanshu471/ad-management/llms.txt
Use this file to discover all available pages before exploring further.
useUser store updates session state and the app automatically redirects you to the dashboard that corresponds to your assigned role — /admin, /advertiser, or /creator.
How to Log In
Open the login page
Navigate to
http://localhost:3000/. The root route serves the Login page by default (see LOGIN_ROUTE = "/").Submit the form
Click Sign In. The app calls
useUser().login(), which POSTs your credentials to /api/login.API Request
The login form triggers the following fetch call insideuseUser.login():
hooks/useUser.tsx
email and password, and returns the result.
Successful Response
On a valid match the API returns HTTP 200 with the user object:Error Responses
If login fails, the API returns a plain-text error message with one of the following status codes:| Status | Cause | Message |
|---|---|---|
400 | Wrong email or password | Email or password is incorrect |
500 | Database or server error | Internal server error |
Passwords are currently stored and compared as plain text. For production use, integrate bcrypt (already listed in the project’s dependencies) to hash passwords before saving them and to safely compare them at login time.
Post-Login Session State
After a successful login, theuseUser() store holds the following values for the duration of the browser session:
| Field | Value |
|---|---|
userId | MongoDB _id of the authenticated user |
name | User’s display name |
email | User’s email address |
role | admin, advertiser, or creator |
isLoggedIn | true |