Skip to content

IA-950 : Fix: Password Reset Code Expiration Failing in Production Due to Timezone Mismatch

khadija.elbachouri a demandé de fusionner feature/IA-950 vers develop

Problem

Password reset codes were expiring immediately in the staging environment, even when freshly generated. The issue did not appear in local development.

Root Cause

The LocalDateTime values stored in the database (via Hibernate) and the LocalDateTime.now() used for expiration comparison were inconsistent across environments due to timezone differences between the local JVM (UTC+1) and the production server (UTC).

Changes

  • Added hibernate.jdbc.time_zone: UTC in application-local.yml and application-rec.yml to ensure Hibernate reads/writes timestamps in UTC
  • Applied LocalDateTime.now(ZoneOffset.UTC) specifically in requestPasswordResetCode() for storing expiration timestamps
  • Applied LocalDateTime.now(ZoneOffset.UTC) in confirmPasswordResetCode() for comparing expiration timestamps
  • Applied LocalDateTime.now(ZoneOffset.UTC) in 2FA code generation and verification methods

Scope

Only expiration-related timestamp comparisons are affected. Other LocalDateTime.now() usages (lastLogin, etc.) remain unchanged.

Rapports de requête de fusion