-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from Jiayan-Lim/user-ui
User UI
- Loading branch information
Showing
35 changed files
with
3,339 additions
and
362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,17 @@ PORT=3001 | |
# Will use cloud MongoDB Atlas database | ||
ENV=PROD | ||
|
||
# email details | ||
EMAIL_USER=[email protected] | ||
EMAIL_PASS=vhgj idnk fhme ooim | ||
|
||
# backup email | ||
BACKUP_EMAIL_USER=[email protected] | ||
BACKUP_EMAIL_PASS=vvkj xhtv twsf roeh | ||
|
||
# frontend host | ||
FRONTEND_HOST=http://localhost | ||
FRONTEND_PORT=3000 | ||
|
||
# Secret for creating JWT signature | ||
JWT_SECRET=you-can-replace-this-with-your-own-secret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,9 +61,32 @@ | |
|-----------------------------|-------------------------------------------------------| | ||
| 201 (Created) | User created successfully, created user data returned | | ||
| 400 (Bad Request) | Missing fields | | ||
| 403 (Forbidden) | User hasn't verified their email | | ||
| 409 (Conflict) | Duplicate username or email encountered | | ||
| 500 (Internal Server Error) | Database or server error | | ||
|
||
### Check User Exist by Email or Id | ||
|
||
- This endpoint allows checking if a user exists in the database based on their email address. | ||
|
||
- HTTP Method: `GET` | ||
|
||
- Endpoint: http://localhost:3001/users/check | ||
|
||
- Parameters | ||
- Required: at least one of `email`, `id` path parameter | ||
- Example: `http://localhost:3001/[email protected]` | ||
|
||
- Responses: | ||
|
||
| Response Code | Explanation | | ||
|-----------------------------|----------------------------------------------------------| | ||
| 200 (OK) | User found | | ||
| 400 (Bad Request) | Bad request, parameter is missing. | | ||
| 404 (Not Found) | User with the specified email not found | | ||
| 500 (Internal Server Error) | Database or server error | | ||
|
||
|
||
### Get User | ||
|
||
- This endpoint allows retrieval of a single user's data from the database using the user's ID. | ||
|
@@ -134,13 +157,14 @@ | |
- Required: `userId` path parameter | ||
|
||
- Body | ||
- At least one of the following fields is required: `username` (string), `email` (string), `password` (string) | ||
- At least one of the following fields is required: `username` (string), `email` (string), `password` (string), `isVerified` (boolean) | ||
|
||
```json | ||
{ | ||
"username": "SampleUserName", | ||
"email": "[email protected]", | ||
"password": "SecurePassword" | ||
"password": "SecurePassword", | ||
"isVerified": true, | ||
} | ||
``` | ||
|
||
|
@@ -253,6 +277,7 @@ | |
| 200 (OK) | Login successful, JWT token and user data returned | | ||
| 400 (Bad Request) | Missing fields | | ||
| 401 (Unauthorized) | Incorrect email or password | | ||
| 403 (Unauthorized) | User hasn't verified their email | | ||
| 500 (Internal Server Error) | Database or server error | | ||
|
||
### Verify Token | ||
|
@@ -269,4 +294,129 @@ | |
|-----------------------------|----------------------------------------------------| | ||
| 200 (OK) | Token verified, authenticated user's data returned | | ||
| 401 (Unauthorized) | Missing/invalid/expired JWT | | ||
| 500 (Internal Server Error) | Database or server error | | ||
| 500 (Internal Server Error) | Database or server error | | ||
|
||
### Send Email | ||
|
||
- This endpoint allows sending an email to the user. | ||
- HTTP Method: `POST` | ||
- Endpoint: http://localhost:3001/email//send-verification-email | ||
- Body | ||
- Required: `email` (string), `title` (string), `html` (string) | ||
|
||
```json | ||
{ | ||
"email": "[email protected]", | ||
"title": "Confirm Your Email for PeerPrep", | ||
"html": "<p>Click the link below to verify your email: </p>" | ||
} | ||
``` | ||
|
||
- Responses: | ||
|
||
| Response Code | Explanation | | ||
|-----------------------------|----------------------------------------------------| | ||
| 200 (OK) | Verification email sent successfully. | | ||
| 400 (Bad Request) | Missing or invalid fields (email, title, html). | | ||
| 500 (Internal Server Error) | Database or server error | | ||
|
||
### Send OTP Email | ||
|
||
- This endpoint allows sending an email containing OTP to the user after they sign up. | ||
- HTTP Method: `POST` | ||
- Endpoint: http://localhost:3001/email//send-otp-email | ||
- Body | ||
- Required: `email` (string), `username` (string) | ||
|
||
```json | ||
{ | ||
"email": "[email protected]", | ||
"password": "Confirm Your Email for PeerPrep", | ||
"html": "<p>Click the link below to verify your email: </p>" | ||
} | ||
``` | ||
|
||
- Responses: | ||
|
||
| Response Code | Explanation | | ||
|-----------------------------|----------------------------------------------------| | ||
| 200 (OK) | Verification email sent successfully. | | ||
| 400 (Bad Request) | Missing or invalid fields (email, title, html). | | ||
| 404 (Not Found) | User with specified email not found | | ||
| 500 (Internal Server Error) | Database or server error | | ||
|
||
### Send Verification Link Email | ||
|
||
- This endpoint sends a verification email containing a verification link to the user after they sign up. | ||
- HTTP Method: `POST` | ||
- Endpoint: http://localhost:3001/email/send-verification-email | ||
- Body | ||
- Required: `email` (string), `username` (string), `id` (string), `type` (string) | ||
|
||
```json | ||
{ | ||
"email": "[email protected]", | ||
"username": "us", | ||
"id": "avid0ud9ay2189rgdbjvdak", | ||
"type": "sign-up" // or "update" | ||
} | ||
``` | ||
|
||
- Responses: | ||
|
||
| Response Code | Explanation | | ||
|-----------------------------|----------------------------------------------------| | ||
| 200 (OK) | Verification email sent successfully. | | ||
| 400 (Bad Request) | Missing or invalid fields (email, title, html). | | ||
| 500 (Internal Server Error) | Database or server error | | ||
|
||
### Verify OTP | ||
|
||
- This endpoint verifies the OTP (One-Time Password) sent to the user and returns a reset token upon success. | ||
- HTTP Method: `POST` | ||
- Endpoint: http://localhost:3001/auth/verif-otp | ||
- Body | ||
- Required: `email` (string), `otp` (string) | ||
|
||
```json | ||
{ | ||
"email": "[email protected]", | ||
"otp": "123456" | ||
} | ||
``` | ||
|
||
- Responses: | ||
|
||
| Response Code | Explanation | | ||
|-----------------------------|-----------------------------------------------------------------| | ||
| 200 (OK) | OTP verified successfully. Returns a reset token | | ||
| 400 | Both email and otp are required fields. | | ||
| 403 | No OTP request found for this user, or OTP expired or incorrect.| | ||
| 404 | User with the provided email not found. | | ||
| 500 | Database or server error | | ||
|
||
### Reset Password | ||
|
||
- This endpoint resets the user’s password if the provided reset token is valid. | ||
- HTTP Method: `POST` | ||
- Endpoint: http://localhost:3001/auth/verif-otp | ||
- Body | ||
- Required: `email` (string), `token` (string), `newPassword` (string) | ||
|
||
```json | ||
{ | ||
"email": "[email protected]", | ||
"token": "reset_token_value", | ||
"newPassword": "newpassword123" | ||
} | ||
``` | ||
|
||
- Responses: | ||
|
||
| Response Code | Explanation | | ||
|-----------------------------|---------------------------------------------------------------------------| | ||
| 200 (OK) | OTP verified successfully. Returns a reset token | | ||
| 400 | Missing required fields, token mismatch, expired token, or password reuse.| | ||
| 403 | No OTP request found for this user, or OTP expired or incorrect. | | ||
| 404 | User not found. | | ||
| 500 | Database or server error | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.