This project is a django based API with user authentication and organisation management features.
- User registration and login with JWT Authentication
- Fetching user records and organisations
- Creating and managing organisations
- Adding users to organisations
- Django
- Django REST Framework
- JWT (JSON Web Token) for authentication
- Python 3.x
- Django REST Framework
- Django Simple JWT
- Clone the repository
- Create and activate a virtual environment
- Install the dependencies
- Apply the migrations
- Run the development server
- Method: POST
- Endpoint:
/auth/register
- Description: Registers a new user.
- Example request:
http://127.0.0.1:8000/auth/register
- Example request:
{
"firstName": "Jane",
"lastName": "Doe",
"email": "[email protected]",
"password": "password123",
"phone": "0700000000"
}
- Example response:
{
"status": "success",
"message": "Registration successful",
"data": {
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzIyMjU1NjQ0LCJpYXQiOjE3MjE5OTY0NDQsImp0aSI6ImZhY2U0OTI4YTljZTQwODc5NzM1YmQ0NjU0YjcxODE0IiwidXNlcl9pZCI6MTF9.L37asmGd3Esz0Ive6rX_AXoaH5FzG96Tc_ckH9I9VuY",
"user": {
"userId": "29b7bc0c-56f0-493b-bd14-72d5ac5f7e43",
"firstName": "Jane",
"lastName": "Doe",
"email": "[email protected]",
"phone": "0700000000"
}
}
}
- Method: POST
- Endpoint:
auth/login
- Description: Log in a user
- Example request:
http://localhost:8000/auth/login
{
"email": "[email protected]",
"password": "password123"
}
- Example response:
{
"status": "success",
"message": "Login successful",
"data": {
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzIyMjU1NjQ0LCJpYXQiOjE3MjE5OTY0NDQsImp0aSI6ImZhY2U0OTI4YTljZTQwODc5NzM1YmQ0NjU0YjcxODE0IiwidXNlcl9pZCI6MTF9.L37asmGd3Esz0Ive6rX_AXoaH5FzG96Tc_ckH9I9VuY",
"user": {
"userId": "29b7bc0c-56f0-493b-bd14-72d5ac5f7e43",
"firstName": "Jane",
"lastName": "Doe",
"email": "[email protected]",
"phone": "0700000000"
}
}
}
- Method: POST
- Endpoint:
api/users/<uuid:user_id>
- Description: Retrieve a user's record
- Example request:
http://127.0.0.1:8000/api/users/29b7bc0c-56f0-493b-bd14-72d5ac5f7e43
- Example response:
{
"status": "success",
"message": "User record retrieved successfully.",
"data": {
"userId": "29b7bc0c-56f0-493b-bd14-72d5ac5f7e43",
"firstName": "Jane",
"lastName": "Doe",
"email": "[email protected]",
"phone": "0700000000"
}
}
- Method: GET
- Endpoint:
api/organisations
- Description: Retrieve user organisations
- Example request:
http://127.0.0.1:8000/api/organisations
- Example response:
{
"status": "success",
"message": "Organisations retrieved successfully",
"data": {
"organisations": [
{
"orgId": "d04ddeaa-65d6-4e6b-9528-8b89f2283271",
"name": "Jane's Organisation",
"description": "Default Organization"
},
{
"orgId": "38847369-651f-4d9a-929a-47510e31cc74",
"name": "My organisation",
"description": "Jane's created organization"
}
]
}
}
- Method: GET
- Endpoint:
api/organisations/<uuid:org_id>
- Description: Retrieve organisation record
- Example Request:
http://127.0.0.1:8000/api/organisations/d04ddeaa-65d6-4e6b-9528-8b89f2283271
- Example Response:
{
"status": "success",
"message": "Organisation details retrieved successfully",
"data": {
"orgId": "d04ddeaa-65d6-4e6b-9528-8b89f2283271",
"name": "Jane's Organisation",
"description": "Default Organization"
}
}
- Method: POST
- Endpoint:
api/organisations/create
- Description: Create custom organisation
- Example request: http://127.0.0.1:8000/api/organisations/create
- Example Response:
{
"status": "success",
"message": "Organisation created successfully",
"data": {
"orgId": "0a2f5254-0991-4865-bb84-942331f7d6f0",
"name": "Third organisation",
"description": "My third organisation"
}
}
- Method: POST
- Endpoint:
api/organisations/<uuid:org_id>/users
- Description: Add user to an organisation
- Example request:
http://127.0.0.1:8000/api/organisations/0a2f5254-0991-4865-bb84-942331f7d6f0/users
- Example response:
{
"status": "success",
"message": "user added to organisation successfully"
}