Updated login docs

This commit is contained in:
Alex Holliday committed 2024-07-24 11:11:41 -07:00
1 parent 708c483876
commit b39e80b9da
1 file changed
+53 -21
+53 -21
View File
@@ -319,22 +319,22 @@ Example:
##### Response Payload ##### Response Payload
> | Type | Notes | > | Type | Notes |
> | ---- | ---------------------------------- | > | ---- | -------------- |
> | JWT | JSON Web Token containing a `User` | > | User | User data |
> | JWT | JSON web token |
##### Sample CURL request ##### Sample CURL request
``` ```
curl --request POST \ curl --request POST \
--url http://localhost:5000/api/v1/auth/register \ --url http://localhost:5000/api/v1/auth/register \
--header 'Content-Type: application/json' \ --header 'Content-Type: multipart/form-data' \
--data '{ --form firstName=Alex \
"firstname" : "User First Name", --form lastName=Hollidaty \
"lastname": "User Last Name", --form email=ajhollid@gmail.com \
"email" : "user@gmail.com", --form 'password=Testtest1!' \
"password": "user_password" --form 'role[]=admin'
}'
``` ```
##### Sample Response ##### Sample Response
@@ -342,8 +342,22 @@ curl --request POST \
```json ```json
{ {
"success": true, "success": true,
"msg": "User created", "msg": "User created successfully",
"data": "<encoded_user>" "data": {
"user": {
"_id": "66a1425b873da2207443f192",
"firstName": "First Name",
"lastName": "Last Name",
"email": "name@gmail.com",
"isActive": true,
"isVerified": false,
"role": ["admin"],
"createdAt": "2024-07-24T18:05:15.852Z",
"updatedAt": "2024-07-24T18:05:15.852Z",
"__v": 0
},
"token": "<token>"
}
} }
``` ```
@@ -364,23 +378,25 @@ curl --request POST \
> | Name | Type | Notes | > | Name | Type | Notes |
> | -------- | -------- | ------------------- | > | -------- | -------- | ------------------- |
> | email | `string` | Valid email address | > | email | `string` | Valid email address |
> | password | `string` | Min 8 chars | > | password | `string` | |
##### Response Payload ##### Response Payload
> | Type | Notes | > | Type | Notes |
> | ---- | ---------------------------------- | > | ---- | -------------- |
> | JWT | JSON Web Token Containing a `User` | > | User | User data |
> | JWT | JSON web token |
##### Sample CURL request ##### Sample CURL request
``` ```
curl --request POST \ curl --request POST \
--url http://localhost:5000/api/v1/auth/login \ --url http://localhost:5000/api/v1/auth/login \
--header 'Authorization: Bearer undefined' \
--header 'Content-Type: application/json' \ --header 'Content-Type: application/json' \
--data '{ --data '{
"email" : "user@gmail.com", "email" : "name@gmail.com",
"password": "user_password" "password": "Testtest1!"
}' }'
``` ```
@@ -388,9 +404,25 @@ curl --request POST \
```json ```json
{ {
"success": true, {
"msg": "Found user", "success": true,
"data": "<encoded_user>" "msg": "User logged in successfully",
"data": {
"user": {
"_id": "66a1425b873da2207443f192",
"firstName": "First Name",
"lastName": "Last Name",
"email": "name@gmail.com",
"isActive": true,
"isVerified": false,
"role": ["admin"],
"createdAt": "2024-07-24T18:05:15.852Z",
"updatedAt": "2024-07-24T18:05:15.852Z",
"__v": 0
},
"token": "<token>"
}
}
} }
``` ```