passwordformat checker, test for checkup
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
This commit is contained in:
@@ -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"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user