Skip to main content

AuthUser Entity

The AuthUser entity represents an authenticated user in the system, storing credentials and authentication-related information.

AuthUser Fields

id
UUID
required
Unique identifier for the authenticated user. Automatically generated using @PrePersist if not provided.
name
string
The full name of the user.
birthDate
date
The date of birth of the user in ISO 8601 format (YYYY-MM-DD).
username
string
required
The username for authentication. Must be unique across the system.
password
string
required
The hashed password for the user account.
email
string
required
The email address of the user. Must be unique and is a required field.
createdAt
datetime
Timestamp of when the account was created. Automatically set using @PrePersist and cannot be updated.
isEnabled
boolean
Indicates whether the user account is enabled and can authenticate.
accountNoExpired
boolean
Indicates whether the user account has not expired.
accountNoLocked
boolean
Indicates whether the user account is not locked.
credentialNoExpired
boolean
Indicates whether the user’s credentials (password) have not expired.

UUID and Timestamp Generation

The AuthUser entity uses the @PrePersist callback to automatically generate a UUID and set the creation timestamp:
@PrePersist
public void prePersist(){
    if (id == null){
        this.id = UUID.randomUUID();
    }
    this.createdAt = LocalDateTime.now();
}

Constraints

  • Unique Username: The username field has a unique constraint
  • Unique Email: The email field is both required and unique
  • Non-updatable createdAt: The createdAt timestamp cannot be modified after creation

AuthRegisterRequest

Data Transfer Object used for registering a new user account.

Request Fields

name
string
required
The full name of the user. Cannot be blank.Validation: @NotBlank(message = "The username is obligatory")
birthDate
date
required
The date of birth of the user. Must be a past or present date.Validation:
  • @NotNull(message = "The username is obligatory")
  • @PastOrPresent(message = "The date of birth must be a past or present date")
username
string
required
The username for the new account. Cannot be blank.Validation: @NotBlank(message = "The username is obligatory")
password
string
required
The password for the new account. Cannot be blank.Validation: @NotBlank(message = "The password is obligatory")
email
string
required
The email address of the user. Must be a valid email format.Validation:
  • @Email(message = "Must be a valid email address")
  • @NotBlank(message = "Email is required")

Example Request

{
  "name": "John Doe",
  "birthDate": "1990-05-15",
  "username": "johndoe",
  "password": "SecureP@ssw0rd123",
  "email": "[email protected]"
}

AuthRegisterResponse

Data Transfer Object returned after successful user registration.

Response Fields

username
string
The username of the newly registered user.
email
string
The email address of the newly registered user.
message
string
A confirmation message about the registration status.
status
boolean
Indicates the success of the registration operation.

Example Response

{
  "username": "johndoe",
  "email": "[email protected]",
  "message": "User registered successfully",
  "status": true
}

AuthLoginRequest

Data Transfer Object used for user authentication.

Request Fields

username
string
required
The username of the user. Cannot be blank.Validation: @NotBlank(message = "The username is obligatory")
password
string
required
The password of the user. Cannot be blank.Validation: @NotBlank(message = "The password is obligatory")

Example Request

{
  "username": "johndoe",
  "password": "SecureP@ssw0rd123"
}

AuthLoginResponse

Data Transfer Object returned after successful user login.

Response Fields

username
string
The username of the authenticated user.
message
string
A confirmation message about the login status.
status
boolean
Indicates the success of the login operation.
jwt
string
The JWT (JSON Web Token) access token for subsequent authenticated requests. Include this token in the Authorization header as Bearer {jwt}.

Example Response

{
  "username": "johndoe",
  "message": "Login successful",
  "status": true,
  "jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJqb2huZG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
}

Build docs developers (and LLMs) love