Module

AuthModel

Members

authCodeSchema

# inner constant authCodeSchema

View Source API/src/models/token.models.js, line 76

blacklistedTokenSchema

# inner constant blacklistedTokenSchema

View Source API/src/models/token.models.js, line 65

passwordSchema

# inner constant passwordSchema

View Source API/src/models/password.models.js, line 31

Methods

# inner comparePassword(password) → {boolean}

This method is used to compare the user password with the password.

Parameters:
Name Type Description
password string
See:

View Source API/src/models/password.models.js, line 65

boolean

# inner updatePassword(newPassword)

This method is used to update the user password. it first hashes the new password and then saves it to the database.

Parameters:
Name Type Description
newPassword string

View Source API/src/models/password.models.js, line 51

Type Definitions

Object

# authCodeSchema

This schema is used to store verification codes for user authentication, such as the verification code for email verification, the password reset code.


NOTE: The activation and deactivation codes are only used for superadmin account activation and deactivation.

Properties:
Name Type Attributes Description
user ObjectId

The user to whom the code belongs

verification_code String

The verification code

password_reset_code String

The password reset code

activation_code String <optional>

The account activation code, for superadmin account activation

deactivation_code String <optional>

The account deactivation code, for superadmin account deactivation

createdAt Date

The date the code was created

See:

View Source API/src/models/token.models.js, line 38

Object

# blacklistedTokenSchema

This schema is used to store blacklisted JWT tokens, so that they can be checked against when a user tries to access a protected route


NOTE: The token expiry is set to the same as the refresh token expiry. because the no valid JWT will last longer than the refresh token. This value can be modified in the config file.

Properties:
Name Type Description
token String

The blacklisted token

createdAt Date

The date the token was blacklisted

expiresAt Date

The date the token will expire,

View Source API/src/models/token.models.js, line 19

Object

# passwordSchema

This schema is used to store user passwords.


NOTE: The password is hashed before being stored in the database.

Properties:
Name Type Description
password String

The user password

user ObjectId

The user to whom the password belongs

See:

View Source API/src/models/password.models.js, line 13

This module contains the models for authentication, such as the blacklisted token model and the auth code model.

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

Requires

  • module:mongoose
  • module:../utils/config

Members

authCodeSchema

# inner constant authCodeSchema

View Source API/src/models/token.models.js, line 76

blacklistedTokenSchema

# inner constant blacklistedTokenSchema

View Source API/src/models/token.models.js, line 65

passwordSchema

# inner constant passwordSchema

View Source API/src/models/password.models.js, line 31

Methods

# inner comparePassword(password) → {boolean}

This method is used to compare the user password with the password.

Parameters:
Name Type Description
password string
See:

View Source API/src/models/password.models.js, line 65

boolean

# inner updatePassword(newPassword)

This method is used to update the user password. it first hashes the new password and then saves it to the database.

Parameters:
Name Type Description
newPassword string

View Source API/src/models/password.models.js, line 51

Type Definitions

Object

# authCodeSchema

This schema is used to store verification codes for user authentication, such as the verification code for email verification, the password reset code.


NOTE: The activation and deactivation codes are only used for superadmin account activation and deactivation.

Properties:
Name Type Attributes Description
user ObjectId

The user to whom the code belongs

verification_code String

The verification code

password_reset_code String

The password reset code

activation_code String <optional>

The account activation code, for superadmin account activation

deactivation_code String <optional>

The account deactivation code, for superadmin account deactivation

createdAt Date

The date the code was created

See:

View Source API/src/models/token.models.js, line 38

Object

# blacklistedTokenSchema

This schema is used to store blacklisted JWT tokens, so that they can be checked against when a user tries to access a protected route


NOTE: The token expiry is set to the same as the refresh token expiry. because the no valid JWT will last longer than the refresh token. This value can be modified in the config file.

Properties:
Name Type Description
token String

The blacklisted token

createdAt Date

The date the token was blacklisted

expiresAt Date

The date the token will expire,

View Source API/src/models/token.models.js, line 19

Object

# passwordSchema

This schema is used to store user passwords.


NOTE: The password is hashed before being stored in the database.

Properties:
Name Type Description
password String

The user password

user ObjectId

The user to whom the password belongs

See:

View Source API/src/models/password.models.js, line 13