Overview
This is a project designed to implement user management features, including:
- Register / Login
- Reset password
- Integrate social login API
- Assign permissions by roles, capabilities and departments.
- Back-end uses PHP, Go and Node.js
- Front-end uses ReactJS
- Database uses MySQL
- Server uses Amazon EC2 T2 + Ubuntu to run code, Amazon RDS + MySQL to run database.
Demo
Design Database
The database includes the following tables:
- users
- social_accounts
- password_resets
- roles
- capabilities
- departments
- user_roles
- role_capabilities
- user_departments
Table users
| Column | Type | Description |
|---|
| id | BIGINT (PK) | Primary Key |
| email | VARCHAR(255) | User email, unique |
| password_hash | VARCHAR(255) | Password encoding |
| name | VARCHAR(255) | Display name |
| is_active | BOOLEAN | Status |
| created_at | DATETIME | Date created |
| updated_at | DATETIME | Date updated |
Table social_accounts
| Column | Type | Description |
|---|
| id | BIGINT (PK) | Primary Key |
| user_id | BIGINT (FK) | Links to users |
| provider | VARCHAR(50) | google, facebook, github… |
| provider_user_id | VARCHAR(255) | User ID from provider |
| created_at | DATETIME | Time of link |
Table password_resets
| Column | Type | Description |
|---|
| id | BIGINT (PK) | Primary Key |
| user_id | BIGINT (FK) | Links to users |
| token | VARCHAR(255) | Authentication Token |
| expires_at | DATETIME | Expiration date |
| created_at | DATETIME | Date created |
Table roles
| Column | Type | Description |
|---|
| id | INT (PK) | Primary Key |
| name | VARCHAR(100) | Role name, e.g.: admin, editor, viewer |
Table capabilities
| Column | Type | Description |
|---|
| id | INT (PK) | Primary Key |
| name | VARCHAR(100) | E.g.: edit_post, delete_user, view_report |
Table departments
| Column | Type | Description |
|---|
| id | INT (PK) | Primary Key |
| name | VARCHAR(100) | Deparment name, e.g.: IT, Sales, HR |
Table user_roles
| Column | Type | Description |
|---|
| user_id | BIGINT (FK) | Links to users |
| role_id | INT (FK) | Links to roles |
Table role_capabilities
| Column | Type | Description |
|---|
| role_id | INT (FK) | Role |
| capability_id | INT (FK) | Capability |
Table user_departments
| Column | Type | Description |
|---|
| user_id | BIGINT (FK) | User |
| department_id | INT (FK) | Department |
Set up server
Implement Back-end code