mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-02-09 12:29:13 +00:00
recovery del pass hecho en el backend a falta de hacer los formularios
This commit is contained in:
102
src/main/java/com/imprimelibros/erp/auth/PasswordResetToken.java
Normal file
102
src/main/java/com/imprimelibros/erp/auth/PasswordResetToken.java
Normal file
@ -0,0 +1,102 @@
|
||||
package com.imprimelibros.erp.auth;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.time.Instant;
|
||||
|
||||
@Entity
|
||||
@Table(name = "password_reset_tokens", indexes = {
|
||||
@Index(name = "idx_prt_token_hash", columnList = "tokenHash"),
|
||||
@Index(name = "idx_prt_user_id", columnList = "userId")
|
||||
})
|
||||
public class PasswordResetToken {
|
||||
|
||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false) private Long userId;
|
||||
|
||||
@Column(nullable = false, length = 128)
|
||||
private String tokenHash; // SHA-256 hex
|
||||
|
||||
@Column(nullable = false)
|
||||
private Instant expiresAt;
|
||||
|
||||
@Column(nullable = false)
|
||||
private Instant createdAt = Instant.now();
|
||||
|
||||
private Instant usedAt;
|
||||
|
||||
// Auditoría ligera (GDPR: documéntalo y limita retención)
|
||||
@Column(length = 64)
|
||||
private String requestIp;
|
||||
|
||||
@Column(length = 255)
|
||||
private String userAgent;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getTokenHash() {
|
||||
return tokenHash;
|
||||
}
|
||||
|
||||
public void setTokenHash(String tokenHash) {
|
||||
this.tokenHash = tokenHash;
|
||||
}
|
||||
|
||||
public Instant getExpiresAt() {
|
||||
return expiresAt;
|
||||
}
|
||||
|
||||
public void setExpiresAt(Instant expiresAt) {
|
||||
this.expiresAt = expiresAt;
|
||||
}
|
||||
|
||||
public Instant getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Instant createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Instant getUsedAt() {
|
||||
return usedAt;
|
||||
}
|
||||
|
||||
public void setUsedAt(Instant usedAt) {
|
||||
this.usedAt = usedAt;
|
||||
}
|
||||
|
||||
public String getRequestIp() {
|
||||
return requestIp;
|
||||
}
|
||||
|
||||
public void setRequestIp(String requestIp) {
|
||||
this.requestIp = requestIp;
|
||||
}
|
||||
|
||||
public String getUserAgent() {
|
||||
return userAgent;
|
||||
}
|
||||
|
||||
public void setUserAgent(String userAgent) {
|
||||
this.userAgent = userAgent;
|
||||
}
|
||||
|
||||
// getters/setters
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user