docs: add instructions for obtaining admin token in API docs
This commit is contained in:
parent
e9be91876e
commit
aef45866fb
1 changed files with 24 additions and 0 deletions
|
|
@ -11,6 +11,30 @@ ### POST /api/logout
|
||||||
- **Description**: Logout the user and revoke the token.
|
- **Description**: Logout the user and revoke the token.
|
||||||
- **Response**: JSON object with a success message.
|
- **Response**: JSON object with a success message.
|
||||||
|
|
||||||
|
### Obtaining an Admin Token
|
||||||
|
- **Description**: To obtain a token for an admin user, follow these steps:
|
||||||
|
1. **Ensure the Admin User Exists**: Make sure there is an admin user in the database. If not, create one using the following command:
|
||||||
|
```bash
|
||||||
|
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
|
||||||
|
```
|
||||||
|
2. **Authenticate the Admin User**: Use the `/api/login` endpoint to authenticate the admin user and obtain the token. Send a POST request with the admin user's credentials:
|
||||||
|
```bash
|
||||||
|
curl -X POST http://your-app-url/api/login -H "Content-Type: application/json" -d '{"email":"admin@example.com","password":"password"}'
|
||||||
|
```
|
||||||
|
3. **Response**: The response will include a JSON object with the generated token:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"token": "your-generated-token"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Admin Management
|
## Admin Management
|
||||||
|
|
||||||
### GET /api/admin/users
|
### GET /api/admin/users
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue