Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/diarpicu2022-commits/backend-AgroPulse/llms.txt

Use this file to discover all available pages before exploring further.

The login endpoint accepts two authentication paths: standard credential login (username or email plus password) and Google login (email only, or with a googleId). On success it returns the sanitized user object — no password hash is ever included. Accounts that sign in via Google are auto-created on first login with the OPERATOR role.

Request body

Provide either username or email together with password.
username
string
The user’s unique username. Used as the primary lookup key. Either username or email must be present.
email
string
The user’s email address. Used as a fallback lookup when username is not supplied.
password
string
required
The user’s password in plain text. Verified against the stored BCrypt hash. Legacy plain-text passwords are automatically upgraded to BCrypt on first successful login.

Response

A 200 OK response returns the user object directly.
id
number
required
Auto-incremented integer primary key.
username
string
required
Unique username. For Google-created accounts this is set to the user’s email address.
fullName
string
The user’s display name.
email
string
The user’s email address.
phone
string
Optional phone number.
avatar
string
URL of the user’s profile picture.
role
string
required
The user’s role. One of ADMIN, AGRONOMIST, OPERATOR, VIEWER, or USER.
active
boolean
required
Whether the account is active. Defaults to true on creation.
createdAt
string
required
ISO 8601 datetime when the account was created.
greenhouseIds
number[]
required
List of greenhouse IDs the user has access to. Empty array if none are assigned.

Error responses

Statuserror valueCause
401Usuario no encontradoNo user matched the provided username or email.
401Contraseña incorrectaThe password did not match the stored hash.

Examples

curl --request POST \
  --url http://localhost:8080/api/auth/login \
  --header 'Content-Type: application/json' \
  --data '{
    "username": "john_doe",
    "password": "s3cr3tPass"
  }'

Success response

{
  "id": 42,
  "username": "john_doe",
  "fullName": "John Doe",
  "email": "john@example.com",
  "phone": null,
  "avatar": null,
  "role": "OPERATOR",
  "active": true,
  "createdAt": "2024-03-15T10:22:00",
  "greenhouseIds": [1, 3]
}

Error response

{
  "error": "Contraseña incorrecta"
}

Build docs developers (and LLMs) love