Skip to main content

Documentation 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.

Registering an account creates a new user document in MongoDB and immediately signs you in. During registration you choose one of three roles — admin, advertiser, or creator — which determines which dashboard you are routed to and which features you can access for the entire lifetime of that account.

Registration Form Fields

The registration form collects four pieces of information:
FieldTypeRequiredDescription
namestringYesYour display name shown across the platform
emailstringYesMust be unique — duplicate emails are rejected
passwordstringYesYour account password
rolestringYesadmin, advertiser, or creator

How to Register

1

Open the registration page

Navigate to http://localhost:3000/register (see REGISTER_ROUTE = "/register").
2

Fill in your details

Enter your Name, Email, and Password in the corresponding fields.
3

Select your role

Choose a role from the dropdown:
  • Admin — full platform management access
  • Advertiser — campaign creation and analytics
  • Content Creator — campaign browsing and profile management
4

Submit the form

Click Sign In. The app calls useUser().register(), which POSTs your details to /api/register.
5

Get redirected

On success, your account is created in MongoDB, session state is set in useUser, and you are redirected to your role’s dashboard (/admin, /advertiser, or /creator).

API Request

The registration form triggers the following fetch call inside useUser.register():
hooks/useUser.tsx
const res = await fetch("/api/register", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ name, email, password, role }),
});
The server handler checks for an existing user with the same email before creating the new document.

Successful Response

On successful account creation the API returns HTTP 200 with the new user object:
{
  "newUser": {
    "_id": "65f1a2b3c4d5e6f7a8b9c0d1",
    "name": "john doe",
    "email": "john@example.com",
    "role": "advertiser",
    "createdAt": "2024-01-15T10:30:00.000Z"
  }
}

Error Responses

StatusCauseMessage
400Email already registeredEmail is already in use
500Database or server errorInternal server error
If a 400 is returned, try signing in with the existing account instead, or use a different email address.
Passwords are currently stored in MongoDB 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. Never store plain-text passwords in a production database.

Build docs developers (and LLMs) love