java.lang.Object
me.josephsf.jobportaljosephsfeir.model.User

public class User extends Object
Model class representing a user account in the Job Portal system.

The User entity stores essential authentication and identification information for all users of the system, regardless of their role. Each user can have one or more roles (Candidate, Recruiter, or Admin) which determine their access rights.

User accounts are stored in the "users" collection in MongoDB. The username and email fields are indexed with unique constraints to ensure no duplicates.

User documents contain:

  • Basic identification (username, email)
  • Authentication credentials (password - stored encoded)
  • Role assignments (roles)
  • Audit timestamps (createdAt, updatedAt)

This class is used as the foundation for authentication and authorization throughout the application. Users with Candidate or Recruiter roles will typically have associated profile documents in the respective collections.

Since:
2025-05-15
See Also:
  • Constructor Details

    • User

      public User()
      Default constructor. Initializes creation and update timestamps to current time.
    • User

      public User(String username, String email, String password)
      Constructor with essential user details. Initializes a new user with username, email, and password.
      Parameters:
      username - the user's login name
      email - the user's email address
      password - the user's password (should be encoded before passing)
  • Method Details

    • getId

      public String getId()
      Gets the user's unique identifier.
      Returns:
      the user ID
    • setId

      public void setId(String id)
      Sets the user's unique identifier.
      Parameters:
      id - the user ID to set
    • getUsername

      public String getUsername()
      Gets the user's username.
      Returns:
      the username
    • setUsername

      public void setUsername(String username)
      Sets the user's username.
      Parameters:
      username - the username to set
    • getEmail

      public String getEmail()
      Gets the user's email address.
      Returns:
      the email address
    • setEmail

      public void setEmail(String email)
      Sets the user's email address.
      Parameters:
      email - the email address to set
    • getPassword

      public String getPassword()
      Gets the user's password (encoded).
      Returns:
      the encoded password
    • setPassword

      public void setPassword(String password)
      Sets the user's password. Note: The password should be encoded before setting.
      Parameters:
      password - the encoded password to set
    • getRoles

      public Set<Role> getRoles()
      Gets the set of roles assigned to the user.
      Returns:
      the set of roles
    • setRoles

      public void setRoles(Set<Role> roles)
      Sets the roles for the user.
      Parameters:
      roles - the set of roles to assign
    • getCreatedAt

      public LocalDateTime getCreatedAt()
      Gets the timestamp when the user account was created.
      Returns:
      the creation timestamp
    • setCreatedAt

      public void setCreatedAt(LocalDateTime createdAt)
      Sets the creation timestamp for the user account.
      Parameters:
      createdAt - the creation timestamp to set
    • getUpdatedAt

      public LocalDateTime getUpdatedAt()
      Gets the timestamp when the user account was last updated.
      Returns:
      the last update timestamp
    • setUpdatedAt

      public void setUpdatedAt(LocalDateTime updatedAt)
      Sets the last update timestamp for the user account.
      Parameters:
      updatedAt - the update timestamp to set