debt-pirate/bruno/Debt Pirate/auth/login.bru

41 lines
650 B
Text

meta {
name: login
type: http
seq: 1
}
post {
url: {{protocol}}//{{domain}}/auth/login
body: json
auth: none
}
headers {
Accept: application/json; charset=utf-8
Content-Type: application/json; charset=utf-8
}
body:json {
{
"email": "{{email}}",
"password": "{{password}}"
}
}
script:post-response {
const body = res.getBody();
const data = body.data;
if (res.status < 300) {
bru.setEnvVar("userId", data.id);
if (data.auth?.token) {
bru.setEnvVar("authToken", data.auth.token);
}
if (data.session?.token) {
bru.setEnvVar("sessionToken", data.session.token);
}
}
}