passwordformat checker, test for checkup
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good

This commit is contained in:
Daniel
2026-02-18 15:37:02 +01:00
parent cc6028bab5
commit e1f8cf123b
3 changed files with 40 additions and 2 deletions
@@ -59,6 +59,13 @@ public class AuthenticationService {
this.emailService = emailService;
}
private boolean isPasswordFormatCorrect(String password) {
//insert other check ups for passwords
if(password.length() < 8) return false;
return true;
}
public RegistrationResponseDTO registerUser(UserRegistrationDTO registrationDTO) {
try {
// check if mail is already in use
@@ -77,6 +84,9 @@ public class AuthenticationService {
return new RegistrationResponseDTO(null, null, RegistrationStatus.EMAIL_INVALID);
}
//validate Password
if(!isPasswordFormatCorrect(registrationDTO.getPassword())) return new RegistrationResponseDTO(null, null, RegistrationStatus.PASSWORD_INVALID);
// encode password
String encodedPassword = passwordEncoder.encode(registrationDTO.getPassword());
@@ -166,6 +176,10 @@ public class AuthenticationService {
throw new InvalidTokenException("Code ist ungültig");
}
if(!isPasswordFormatCorrect(passwordResetDTO.getNew_password())) {
throw new InvalidTokenException("Passwortformat ist nicht korrekt");
}
User user = userRepository.findByEmail(passwordResetDTO.getEmail())
.orElseThrow(() -> new UsernameNotFoundException("User existiert nicht"));