Module

UserModel

This module contains the user model and its submodels, users are the main entities in the system, they are the ones who can access the API, each user has a role, which determines the level of access they have to the API.


The role of a user can be one of the following:

  • EndUser - A regular user, who can access the API and use it to perform CRUD operations on the database.

  • Admin - A user who can access the API and use it to perform CRUD operations on the database, but they can only access the data that they have created.

  • SuperAdmin - A user who can access the API and use it to perform CRUD operations on the database, but they can only access the data that they have created, they can also create, update and delete users.

View Source API/src/models/user.models.js, line 1

Requires

  • module:mongoose
  • module:../utils/errors
  • module:validator
  • module:./token.models

Members

statusSchema

# inner constant statusSchema

View Source API/src/models/user.models.js, line 85

userSchema

# inner constant userSchema

View Source API/src/models/user.models.js, line 94

Type Definitions

Object

# statusSchema

User account status, every user has a status object, which contains information about the user's account status, such as whether the account is active or not, and whether the account is verified or not.



Note: By default, for new users with the role EndUser, their account will be active and unverified . If the user is an admin or superadmin, the account is inactive and unverified by default.

Properties:
Name Type Description
user ObjectId

The user to whom the status belongs

isActive Boolean

Whether the account is active or not

isVerified Boolean

Whether the account is verified or not

See:

View Source API/src/models/user.models.js, line 60

Object

# userSchema

This schema is used to store user information

Properties:
Name Type Attributes Description
firstname String

The user's first name

lastname String

The user's last name

email String

The user's email

role String

The user's role (EndUser, Admin, SuperAdmin)

googleId String <optional>

The user's google id

githubId String <optional>

The user's github id

password MongooseVirtualType

The user's password object

status MongooseVirtualType

The user's status object

auth_codes MongooseVirtualType

The user's auth codes

enrolled_courses MongooseVirtualType

The courses the user is enrolled in

createdAt Date

The date the user was created

updatedAt Date

The date the user was last updated

See:

View Source API/src/models/user.models.js, line 36