Link Search Menu Expand Document

Register

/api/v2/user/register

Post

users

profiles

notifications


Purpose

To allow an user to register on the platform.

Body Content [input]

{
    name: string,
    username: string,
    email: string,
    password: string
}

Returns if valid [output]

{
    message: string,
    error: 0
}

What the API does

  • Checks if the email supplied is already in use [401].
  • Checks if the username supplied is already in use [401].
  • Checks if the name supplied is valid using a regex expression [400].
  • Checks if the username supplied is valid using a regex expression [400].
  • Checks if the email supplied is valid using a regex expression [400].
  • Checks if the password supplied contains at least 1 lowercase alphabet, 1 uppercase alphabet, 1 numerical character and that it is at least 8 characters long [400].
  • Generates a token and a uid.
  • Sends a mail to the email address with the following link: https://api.konnect.dev/api/v2/user/confirm/${username}/${token}.
  • Inserts a new record in the users collection with a known uid, token, name, username, email and prev_email, and a hashed version of password, and uses a default value of false for active, reset and deactivated.
  • Inserts a new record in the profiles collection with a known value for the uid field, inserts a new object in the collections field with a name of “_default”, a generated value for collectionID, and en empty array for the posts field, and uses empty or default values for the bio, profile_pic, cover_image, followers, following, blocked, prefer_dark, account_type, received_follow_requests, sent_follow_requests, chat_invites, searches, access_groups and highlights fields.
  • Generates a new notificationID and a timestamp corresponding to the current date and time, and creates a new object in the notifications collection with the following data:
    {
      uid: uid,
      notificationID: notificationID,
      content: "Welcome to Konnect! 🥳",
      profileID: uid,
      type: "register",
      created_on: timestamp,
      read: false,
      redirect: "/"
    }