Skip to content

Commit

Permalink
changes in readme
Browse files Browse the repository at this point in the history
Signed-off-by: Tanmay Vaij <tanmayvaij22@gmail.com>
  • Loading branch information
tanmayvaij committed Jun 14, 2024
1 parent 8c7b3cc commit cab0dbf
Showing 1 changed file with 12 additions and 84 deletions.
96 changes: 12 additions & 84 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,98 +88,26 @@ UAuthX is a user authentication system built with Node.js and MongoDB. It provid

## Usage

### Register a User
| **Endpoint** | **Request Type** | **Request Body / Headers** | **Success Response** | **Error Response** |
|------------------------|-------------------------|-----------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|
| **Register a User** | POST `/auth/sign-up` | ```json { "email": "user@example.com", "password": "password123" } ``` | ```json { "isSuccess": true, "authToken": "your_jwt_token" } ``` | ```json { "isSuccess": false, "error": "Error message" } ``` |
| **Login** | POST `/auth/sign-in` | ```json { "email": "user@example.com", "password": "password123" } ``` | ```json { "isSuccess": true, "authToken": "your_jwt_token" } ``` | ```json { "isSuccess": false, "error": "Error message" } ``` |
| **Verify User Token** | GET `/auth/verify-user` | Header: Authorization: Bearer your_jwt_token | ```json { "isSuccess": true, "userId": "user_id_string" } ``` | ```json { "isSuccess": false, "error": "Error message" } ``` |

Send a POST request to `/auth/sign-up` with the following JSON body:

```json
{
"email": "user@example.com",
"password": "password123"
}
```

#### Response

- Success:
```json
{
"isSuccess": true,
"authToken": "your_jwt_token"
}
```

- Error:
```json
{
"isSuccess": false,
"error": "Error message"
}
```

### Login

Send a POST request to `/auth/sign-in` with the following JSON body:

```json
{
"email": "user@example.com",
"password": "password123"
}
```

#### Response

- Success:
```json
{
"isSuccess": true,
"authToken": "your_jwt_token"
}
```

- Error:
```json
{
"isSuccess": false,
"error": "Error message"
}
```

### Verify User Token
### Access Protected Routes

Send a GET request to `/auth/verify-user` with the Authorization header containing the Bearer token:
To access protected routes, include the JWT token in the Authorization header of your requests:

```
GET /auth/verify-user HTTP/1.1
Host: localhost:5000
Authorization: Bearer your_jwt_token
```

#### Response

- Success:
```json
{
"isSuccess": true,
"userId": "user_id_string"
}
```
### Access Admin Routes

- Error:
```json
{
"isSuccess": false,
"error": "Error message"
}
```
To access admin routes, use Basic Authentication with your admin username and password.

### Access Protected Routes

To access protected routes, include the JWT token in the Authorization header of your requests:

```
Authorization: Bearer your_jwt_token
```plaintext
Authorization: Basic base64_encode(username:password)
```

---
---

0 comments on commit cab0dbf

Please sign in to comment.