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
userscollection with a knownuid,token,name,username,emailandprev_email, and a hashed version ofpassword, and uses a default value offalseforactive,resetanddeactivated. - Inserts a new record in the
profilescollection with a known value for theuidfield, inserts a new object in thecollectionsfield with anameof “_default”, a generated value forcollectionID, and en empty array for thepostsfield, 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_groupsandhighlightsfields. - Generates a new
notificationIDand atimestampcorresponding to the current date and time, and creates a new object in thenotificationscollection with the following data:{ uid: uid, notificationID: notificationID, content: "Welcome to Konnect! 🥳", profileID: uid, type: "register", created_on: timestamp, read: false, redirect: "/" }