- Move all files from bruno-yaml/* to bruno/* - Maintains existing directory structure within categories - Updates bruno/user/auth files with OAuth2 refresh token flow - Updates bruno/user/profile files for user profile management - Adds bruno/dashboard/ directory with dashboard API tests - Preserves all existing test scenarios and OpenCollection YAML format - No functional changes - file reorganization only
78 lines
1.8 KiB
YAML
78 lines
1.8 KiB
YAML
info:
|
|
name: Login User
|
|
type: http
|
|
seq: 1
|
|
|
|
http:
|
|
method: POST
|
|
url: "{{base_url}}/api/auth/login"
|
|
body:
|
|
type: json
|
|
data: |-
|
|
{
|
|
"login": "testuser@example.com",
|
|
"password": "Test@Pass123!"
|
|
}
|
|
|
|
runtime:
|
|
scripts:
|
|
- type: after-response
|
|
code: |-
|
|
function onResponse(res) {
|
|
try {
|
|
const responseBody = res.getBody();
|
|
const token = responseBody.access_token;
|
|
const refreshToken = responseBody.refresh_token;
|
|
|
|
if (token) {
|
|
bru.setEnvVar("token", token, { persist: true });
|
|
console.log("Access token saved:", token);
|
|
}
|
|
|
|
if (refreshToken) {
|
|
bru.setEnvVar("refresh_token", refreshToken, { persist: true });
|
|
console.log("Refresh token saved:", refreshToken);
|
|
}
|
|
|
|
if (!token && !refreshToken) {
|
|
console.log("No tokens found in response.");
|
|
}
|
|
} catch (error) {
|
|
console.error("Error in post-response script:", error.message);
|
|
}
|
|
}
|
|
onResponse(res);
|
|
|
|
settings:
|
|
encodeUrl: true
|
|
timeout: 0
|
|
followRedirects: true
|
|
maxRedirects: 5
|
|
|
|
docs: |-
|
|
## Login User
|
|
|
|
Authenticates a user with email/username and password.
|
|
|
|
**Method:** POST
|
|
|
|
**Endpoint:** /api/auth/login
|
|
|
|
**Request Body:**
|
|
- `login` (string): Email or username
|
|
- `password` (string): Password
|
|
|
|
**Response:**
|
|
- `token` (string): JWT token
|
|
- `user` (object): User details
|
|
- `id` (string): User ID
|
|
- `email` (string): Email
|
|
- `username` (string): Username
|
|
- `theme` (string): User theme preference
|
|
- `first_name` (string): First name
|
|
- `last_name` (string): Last name
|
|
|
|
**Status Codes:**
|
|
- 200: Success
|
|
- 401: Invalid credentials
|