Skip to content

User Registration API #4

@AchilovMirzojafar

Description

@AchilovMirzojafar

As a backend service
I want to provide a registration endpoint
So that new users can create accounts

Endpoint: POST /api/auth/register

Request Body:

{
  "email": "user@example.com",
  "password": "SecurePass123!"
}

Responsibilities:

  • Validate email format and uniqueness
  • Validate password strength (min 8 chars, at least 1 uppercase, 1 lowercase, 1 number)
  • Hash password using bcrypt
  • Create user document in MongoDB
  • Generate JWT token with user ID and email
  • Return token and user data (excluding password)

Response:

{
  "success": true,
  "token": "jwt_token_here",
  "user": {
    "id": "user_id",
    "email": "user@example.com",
    "createdAt": "2024-01-01T00:00:00Z"
  }
}

Error Handling:

  • 400: Invalid email/password format
  • 409: Email already exists
  • 500: Server error

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions