2.4 KiB
2.4 KiB
API Documentation
Authentication
POST /api/login
- Description: Authenticate a user and generate a token.
- Request Body: JSON object with
emailandpassword. - Response: JSON object with the generated token.
POST /api/logout
- Description: Logout the user and revoke the token.
- Response: JSON object with a success message.
Obtaining an Admin Token
- Description: To obtain a token for an admin user, follow these steps:
- Ensure the Admin User Exists: Make sure there is an admin user in the database. If not, create one using the following command:
php artisan tinker $user = new App\Models\User; $user->name = 'Admin User'; $user->email = 'admin@example.com'; $user->password = bcrypt('password'); $user->role = 'admin'; $user->save(); exit - Authenticate the Admin User: Use the
/api/loginendpoint to authenticate the admin user and obtain the token. Send a POST request with the admin user's credentials:curl -X POST http://your-app-url/api/login -H "Content-Type: application/json" -d '{"email":"admin@example.com","password":"password"}' - Response: The response will include a JSON object with the generated token:
{ "token": "your-generated-token" }
- Ensure the Admin User Exists: Make sure there is an admin user in the database. If not, create one using the following command:
Admin Management
GET /api/admin/users
- Description: Get a list of users (restricted to member users).
- Response: JSON object with a list of users.
POST /api/admin/users/{user}/activate
- Description: Activate a user (restricted to member users).
- Response: JSON object with a success message.
POST /api/admin/users/{user}/deactivate
- Description: Deactivate a user (restricted to member users).
- Response: JSON object with a success message.
Frontend API
GET /api/frontend
- Description: Get frontend data.
- Response: JSON object with a message.
POST /api/frontend
- Description: Store frontend data.
- Request Body: JSON object with required fields.
- Response: JSON object with a success message.
Backend API
GET /api/backend
- Description: Get backend data.
- Response: JSON object with a message.
POST /api/backend
- Description: Store backend data.
- Request Body: JSON object with required fields.
- Response: JSON object with a success message.