Class VerificationTokenEntity

java.lang.Object
com.app.persistence.entity.BaseEntity
com.app.persistence.entity.VerificationTokenEntity

@Entity public class VerificationTokenEntity extends BaseEntity
JPA Entity representing a verification token for user activation.

This class is a JPA entity mapped to the `verification_token` table in the database. It stores the verification token used for user account activation and includes a reference to the associated user. The entity also contains a method to validate the token by checking if it has expired or not based on the stored timestamp.

The entity is linked to the `users` table via a one-to-one relationship with the `UserEntity`. The `timeStamp` represents the expiration time of the token in nanoseconds.

  • Constructor Details

    • VerificationTokenEntity

      public VerificationTokenEntity()
  • Method Details

    • validate

      public Optional<UserEntity> validate()
      Validates the token by checking its expiration time.

      This method checks if the verification token has expired. It returns an Optional containing the associated user if the token is still valid (i.e., its timestamp has not expired), or an empty Optional if the token is expired.

      Returns:
      An Optional containing the user if the token is valid, or an empty Optional if expired.
    • expired

      public boolean expired()