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 knownuid
,token
,name
,username
,email
andprev_email
, and a hashed version ofpassword
, and uses a default value offalse
foractive
,reset
anddeactivated
. - Inserts a new record in the
profiles
collection with a known value for theuid
field, inserts a new object in thecollections
field with aname
of “_default”, a generated value forcollectionID
, and en empty array for theposts
field, and uses empty or default values for thebio
,profile_pic
,cover_image
,followers
,following
,blocked
,prefer_dark
,account_type
,received_follow_requests
,sent_follow_requests
,chat_invites
,searches
,access_groups
andhighlights
fields. - Generates a new
notificationID
and atimestamp
corresponding to the current date and time, and creates a new object in thenotifications
collection with the following data:{ uid: uid, notificationID: notificationID, content: "Welcome to Konnect! 🥳", profileID: uid, type: "register", created_on: timestamp, read: false, redirect: "/" }