-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(auth): Return role when logged in
- Loading branch information
1 parent
b8cba65
commit 64e28c5
Showing
3 changed files
with
73 additions
and
67 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 |
---|---|---|
|
@@ -2,104 +2,110 @@ | |
|
||
- **signup** | ||
|
||
POST | ||
POST | ||
|
||
http://localhost:5000/api/v1/auth/signup | ||
http://localhost:5000/api/v1/auth/signup | ||
|
||
- Example Request | ||
- role → "student" | "instructor" | ||
- password 4-16 letters | ||
- Example Request | ||
|
||
```json | ||
{ | ||
"email":"[email protected]", | ||
"password":"12345678", | ||
"role":"student" | ||
} | ||
``` | ||
- role → "student" | "instructor" | ||
- password 4-16 letters | ||
|
||
- Response | ||
- account created | ||
```json | ||
{ | ||
"email": "[email protected]", | ||
"password": "12345678", | ||
"role": "student" | ||
} | ||
``` | ||
|
||
201 - token | ||
- Response | ||
|
||
```json | ||
{ | ||
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImhhZ2VyQHRlc3QuY29tIiwicm9sZSI6Imluc3RydWN0b3IiLCJpYXQiOjE2MjM2MjMyOTYsImV4cCI6MTYyNDA1NTI5Nn0.0UmSsZCKkbs2zfcJJN6-1h3T1E6DKkAe9Hw5v7uT9zk" | ||
} | ||
``` | ||
- account created | ||
|
||
- validation errors | ||
201 - token | ||
|
||
400 - "Email not Valid", "Password must be between 4 and 16 characters", "No role provided" | ||
```json | ||
{ | ||
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImhhZ2VyQHRlc3QuY29tIiwicm9sZSI6Imluc3RydWN0b3IiLCJpYXQiOjE2MjM2MjMyOTYsImV4cCI6MTYyNDA1NTI5Nn0.0UmSsZCKkbs2zfcJJN6-1h3T1E6DKkAe9Hw5v7uT9zk" | ||
} | ||
``` | ||
|
||
- duplicate accound | ||
- validation errors | ||
|
||
400 - "Account already exists" | ||
400 - "Email not Valid", "Password must be between 4 and 16 characters", "No role provided" | ||
|
||
- Any other error (e.g db connection) | ||
- duplicate accound | ||
|
||
400 - error message | ||
400 - "Account already exists" | ||
|
||
- Any other error (e.g db connection) | ||
|
||
400 - error message | ||
|
||
- **login** | ||
|
||
POST | ||
POST | ||
|
||
http://localhost:5000/api/v1/auth/login | ||
|
||
http://localhost:5000/api/v1/auth/login | ||
- Example Request | ||
|
||
- Example Request | ||
```json | ||
{ | ||
"email": "[email protected]", | ||
"password": "12345678" | ||
} | ||
``` | ||
|
||
```json | ||
{ | ||
"email":"[email protected]", | ||
"password":"12345678" | ||
} | ||
``` | ||
- Response | ||
|
||
- Response | ||
- logged in | ||
- logged in | ||
|
||
201 - token | ||
201 - token | ||
|
||
```json | ||
{ | ||
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImhhZ2VyQHRlc3QuY29tIiwicm9sZSI6Imluc3RydWN0b3IiLCJpYXQiOjE2MjM2MjMyOTYsImV4cCI6MTYyNDA1NTI5Nn0.0UmSsZCKkbs2zfcJJN6-1h3T1E6DKkAe9Hw5v7uT9zk" | ||
} | ||
``` | ||
```json | ||
{ | ||
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImhhZ2VyQHRlc3QuY29tIiwicm9sZSI6Imluc3RydWN0b3IiLCJpYXQiOjE2MjM2MjMyOTYsImV4cCI6MTYyNDA1NTI5Nn0.0UmSsZCKkbs2zfcJJN6-1h3T1E6DKkAe9Hw5v7uT9zk", | ||
"role": "instructor" | ||
} | ||
``` | ||
|
||
- validation errors | ||
- validation errors | ||
|
||
400 - "Email not found", "Password is not correct" | ||
400 - "Email not found", "Password is not correct" | ||
|
||
- Any other error (e.g db connection) | ||
- Any other error (e.g db connection) | ||
|
||
400 - error message | ||
400 - error message | ||
|
||
- **verify** | ||
|
||
POST | ||
POST | ||
|
||
http://localhost:5000/api/v1/auth/verify | ||
|
||
- Example Request | ||
|
||
http://localhost:5000/api/v1/auth/verify | ||
- Header → Authorization = Bearer token | ||
- optional body, for role verification | ||
|
||
- Example Request | ||
- Header → Authorization = Bearer token | ||
- optional body, for role verification | ||
```json | ||
{ | ||
"role": "instructor" | ||
} | ||
``` | ||
|
||
```json | ||
{ | ||
"role":"instructor" | ||
} | ||
``` | ||
- Response | ||
|
||
- Response | ||
- verified | ||
- verified | ||
|
||
200 - verified | ||
200 - verified | ||
|
||
- validation errors | ||
- validation errors | ||
|
||
400 - "Invalid token", "No token provided" | ||
400 - "Invalid token", "No token provided" | ||
|
||
- unauthorized role | ||
- unauthorized role | ||
|
||
400 - "Role not authorized" | ||
400 - "Role not authorized" |
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
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