Handles user-related operations such as registration.
- Source:
Methods
(async, static) loginUser(req, res) → {Promise.<void>}
The function `loginUser` handles user login by validating input, retrieving user data from the database,
comparing the password, generating a JWT token, and sending a response.
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
req |
Object | The HTTP request object, containing information about the incoming request.
Properties
|
|||||||||||||||
res |
Object | The HTTP response object, used to send the response back to the client. |
- Source:
Throws:
-
- Throws an error if validation fails or if there is an issue with database interaction.
- Type
- Error
Returns:
- A promise that resolves to sending a response to the client.
- Type
- Promise.<void>
(async, static) refreshToken(req, res) → {Promise.<void>}
The function `refreshToken` handles refreshing a JWT token by verifying the refresh token,
generating a new JWT token, and sending a response.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
req |
Object | The HTTP request object, containing information about the incoming request.
Properties
|
||||||||||||
res |
Object | The HTTP response object, used to send the response back to the client. |
Throws:
-
- Throws an error if the refresh token is missing or invalid.
- Type
- Error
Returns:
- A promise that resolves to sending a response to the client.
- Type
- Promise.<void>
(async, static) registerUser(req, res) → {Promise.<void>}
The function `registerUser` handles user registration by validating input, hashing the password,
inserting user data into a database, generating a JWT token, and sending a response.
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
req |
Object | The HTTP request object, containing information about the incoming request.
Properties
|
||||||||||||||||||
res |
Object | The HTTP response object, used to send the response back to the client. |
- Source:
Throws:
-
- Throws an error if validation fails or if there is an issue with database interaction.
- Type
- Error
Returns:
- A promise that resolves to sending a response to the client.
- Type
- Promise.<void>