Service for managing user operations in Satoshi Showdown. This service provides comprehensive functionalities for user management, including registration, authentication, profile retrieval, and updates. It caters to both registered and guest users, playing a critical role in user data management and ensuring secure and efficient operations within the application. The service interacts with the user data model and utilizes various utilities for validation, encryption, and logging.
- Source:
Requires
- module:models/userModel
- module:bcrypt
- module:utils/validationUtil
- module:utils/errorUtil
- module:utils/logUtil
Methods
(async, inner) deleteUser(userId) → {Promise.<void>}
Deletes a user from the system based on their unique ID. Essential for account management, data privacy compliance, and user-requested account deletion.
Parameters:
Name | Type | Description |
---|---|---|
userId |
string | The unique ID of the user to delete. |
- Source:
Throws:
-
If no user is found with the provided ID.
- Type
- NotFoundError
Returns:
Indicates successful deletion of the user.
- Type
- Promise.<void>
(async, inner) getAllUsers() → {Promise.<Array.<Object>>}
Retrieves all users registered in the system. Typically used for administrative and reporting purposes, providing a comprehensive view of the user base.
- Source:
Returns:
An array of user objects with sensitive data excluded.
- Type
- Promise.<Array.<Object>>
(async, inner) getUserByEmail(email) → {Promise.<Object>}
Retrieves a user's data by their email. Critical for processes like password recovery or email-based authentication.
Parameters:
Name | Type | Description |
---|---|---|
email |
string | The email of the user to retrieve. |
- Source:
Throws:
-
If no user is found with the provided email.
- Type
- NotFoundError
Returns:
The user object with sensitive data excluded.
- Type
- Promise.<Object>
(async, inner) getUserByIP(ipAddress) → {Promise.<Object>}
Retrieves a user's data by their IP address. Useful for tracking guest users or for security and auditing purposes.
Parameters:
Name | Type | Description |
---|---|---|
ipAddress |
string | The IP address of the user to retrieve. |
- Source:
Throws:
-
If no user is found with the provided IP address.
- Type
- NotFoundError
Returns:
The user object with sensitive data excluded.
- Type
- Promise.<Object>
(async, inner) getUserById(userId) → {Promise.<Object>}
Retrieves a user's data by their unique ID. Essential for profile management, authentication, and accessing user-specific data within the application.
Parameters:
Name | Type | Description |
---|---|---|
userId |
string | The unique ID of the user to retrieve. |
- Source:
Throws:
-
If no user is found with the provided ID.
- Type
- NotFoundError
Returns:
The user object with sensitive data excluded.
- Type
- Promise.<Object>
(async, inner) getUserByUsername(username) → {Promise.<Object>}
Retrieves a user's data by their username. Used for operations like login, where the username is a key identifier.
Parameters:
Name | Type | Description |
---|---|---|
username |
string | The username of the user to retrieve. |
- Source:
Throws:
-
If no user is found with the provided username.
- Type
- NotFoundError
Returns:
The user object with sensitive data excluded.
- Type
- Promise.<Object>
(async, inner) updateUser(userId, updateData) → {Promise.<Object>}
Updates the details of an existing user based on their ID. Allows modification of user information like contact details, preferences, and other profile data.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
userId |
string | The unique ID of the user to update. |
||||||||||||||||||||||||||||||||||||
updateData |
Object | Data containing the updates for the user. Properties
|
- Source:
Throws:
-
If no user is found with the provided ID.
- Type
- NotFoundError
Returns:
The updated user object with sensitive data (e.g., password hash) excluded.
- Type
- Promise.<Object>