Working Implementation for resetting passwords based on a One Time Passcode (OTP). first request Token by stating your email to /request-password-forgot. OTP will be sent via email. Then just type in email, the OTP and a new password to /reset-password.
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
IMPORTANT - EMAIL SETUP in application.properties (if gmail): #mail provider spring.mail.host=smtp.gmail.com spring.mail.port=587 spring.mail.username=<email> # Nutze bei Gmail ein "App-Passwort", nicht dein normales (16 stellig) spring.mail.password=xxxx xxxx xxxx xxxx spring.mail.properties.mail.smtp.auth=true spring.mail.properties.mail.smtp.starttls.enable=true
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package SuMoC.backend.security.models;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Table(name = "OneTimePasswordTokens")
|
||||
@Getter
|
||||
public class PasswordResetToken{
|
||||
|
||||
public static int EXPIRY_TIME_MINUTES = 30;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private String email;
|
||||
private String otp_code;
|
||||
private LocalDateTime expiryDate;
|
||||
|
||||
public PasswordResetToken(String email, String code) {
|
||||
this.email = email;
|
||||
this.otp_code = code;
|
||||
this.expiryDate = LocalDateTime.now().plusMinutes(EXPIRY_TIME_MINUTES);
|
||||
}
|
||||
|
||||
public PasswordResetToken() {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user