Class: UserAPI

UserAPI()

This class contains all the database functions for the users

Constructor

new UserAPI()

Source:

Methods

(async) authUser(user, uid) → {Object}

Single function which handles both sign up and sign in of a user If the user already exists in the database, it simply fetches the existing doucment Or else it creates a new document in the users collection, sets the access level object to level1. Finally uses the Firebase Admin SDK to update the users JWT. Since the user JWT is updated here, after signing up the client has to refresh the token in order to get the updated token from Firebase.

Parameters:
Name Type Description
user Object

user info

uid String

firebase uid

Source:
Returns:

created user object

Type
Object

(async) deleteUser(uid) → {Object}

Deletes the Current User from the database and also from the FIrebase

Parameters:
Name Type Description
uid String
Source:
Throws:

Will throw an error if the user with the given uid is not found.

Returns:

A success response if the user is deleted successfully.

Type
Object

(async) updateUser(args, uid) → {Object}

This function updates the current user's document with all the basic info. It also handles the NITR verification, i.e. the bump from level 1 to level 2. The client is trusted to call this function with the correct institute ID and once the institute ID is set for the first time for a user, it cant be updated again.

Parameters:
Name Type Description
args Object

updated user info

uid String

firebase uid

Source:
Returns:

updated user object

Type
Object