@hsuite/users
A comprehensive user management library for HbarSuite applications that provides robust user authentication, profile management, and security features.
Features
User Management
User registration and account creation
Profile lookup and search functionality
Account deletion and management
Email verification system
Authentication & Security
Secure password management with hashing
Two-factor authentication (2FA) support
Email verification workflows
Password update and recovery processes
Data Management
MongoDB integration with Mongoose
Type-safe data models
Automatic timestamps
Collection management
Installation
Usage
Module Setup
Import the UsersModule in your application:
Basic Usage Examples
User Creation
Finding Users
Security Management
API Reference
UsersService
Core service providing user management functionality:
create(user: User): Promise<UserDocument>
findById(userId: string): Promise<UserDocument>
find(credentials: IAuth.ICredentials.IWeb2.IDto.ILogin): Promise<UserDocument>
updateTwoFactorAuth(userId: string, twoFactorAuth: IAuth.ITwoFactor.IAuth): Promise<UserDocument>
updatePassword(userEmail: string, newPassword: string): Promise<UserDocument>
emailConfirmation(userId: string): Promise<UserDocument>
delete(user: IAuth.ICredentials.IWeb2.IDto.ISignup): Promise<UserDocument>
User Entity
The User entity extends UserNamespace.Safe
and includes:
Required fields:
password
: Hashed password stringAdditional fields inherited from UserNamespace.Safe
Features:
Mongoose schema integration
Automatic timestamps
Pre-save validation
Collection management
Architecture
The library is structured into several key components:
UsersModule: Main module that orchestrates all user-related functionality
UsersService: Core business logic implementation
UserModelModule: Database operations and schema management
User Entity: Data model and validation rules
Database
The library uses MongoDB through Mongoose with the following configuration:
Collection name:
auth_users
Schema features:
Pre-save validation
Automatic timestamps
Secure password hashing
Type-safe fields
Security
Built-in security features include:
Secure password hashing using bcrypt
Two-factor authentication support
Email verification system
Timing attack protection
One-way password hashing
Dependencies
@nestjs/common
@nestjs/mongoose
mongoose
@hsuite/auth-types
@hsuite/users-types
@hsuite/nestjs-swagger
License
[License information not found in source code]
Built with ❤️ by the HbarSuite Team Copyright © 2024 HbarSuite. All rights reserved.
Last updated