registerApi - n1lby73/industrial-IOT GitHub Wiki

Overview

The Registration API endpoint enables user registration by accepting their email, username, and password. Upon successful registration, an email containing a one-time password (OTP) for verification is sent to the provided email address.

Endpoint URL

  • URL: https://industrialiot.onrender.com/api/register
  • Method: POST

Request Parameters

  • Headers:
    • Content-Type: application/json
Parameter Type Description
email String User's email (required).
username String User's desired username (required).
password String User's password (required).

Note: for the register route, it is required of the frontend dev to validate that user is inputing the right password by using the password and confirm password method

Responses

  • Success Response:

    • Status Code: 200 OK
    • Response Body:
      {
          "success": "new user created and otp sent to mail"
          "email": "<users registered email>"
      }
      • Description: Indicates successful user registration and OTP sent to the provided email.
  • Error Responses:

    • Status Code: 400 Bad Request

      • Response Body:
        {
          "error": "username is already taken"
        }
      • Description: Indicates that the provided username already exists.
    • Status Code: 400 Bad Request

      • Response Body:
        {
          "error": "email already exist"
        }
      • Description: Indicates that the provided email is already registered.
    • Status Code: 400 Bad Request

      • Response Body:
        {
          "error": "invalid email format"
        }
      • Description: Indicates that the provided email is not in a correct format.
    • Status Code: 500 Internal Server Error

      • Response Body:
        {
          "error": "failed to create user",
          "details": "<ERROR_DETAILS>"
        }
      • Description: Indicates a server error occurred during user creation.

Usage

  1. Request Method: POST

  2. Endpoint URL: https://industrialiot.onrender.com/api/register

  3. Header: Content-Type: application/json

  4. Request Body: Users data.

    {
        "email": "[email protected]",
        "username": "user123",
        "password": "user_password"
    }

Functionality Details

The registerApi endpoint facilitates user registration with email and username uniqueness constraints. It triggers an email containing an OTP for verification upon successful user creation.

⚠️ **GitHub.com Fallback** ⚠️