RED-6903 - Adjust failure message

This commit is contained in:
Andrei Isvoran 2023-09-18 15:38:21 +03:00
parent 9ace6e25a5
commit 57aa00e096

View File

@ -33,6 +33,8 @@ import lombok.extern.slf4j.Slf4j;
@RequiredArgsConstructor @RequiredArgsConstructor
public class EmailService { public class EmailService {
private final String AUTHENTICATION_UNSUCCESSFUL = "Authentication unsuccessful";
private final String WRONG_USERNAME_PASSWORD = "Username and Password not accepted";
public SMTPResponse.SMTPResponseBuilder send(Map<String, String> config, String address, String subject, String textBody) { public SMTPResponse.SMTPResponseBuilder send(Map<String, String> config, String address, String subject, String textBody) {
@ -121,8 +123,8 @@ public class EmailService {
return SMTPResponse.builder() return SMTPResponse.builder()
.statusCode(200); .statusCode(200);
} catch (Exception e) { } catch (Exception e) {
if (e.getMessage().contains("Authentication unsuccessful, the user credentials were incorrect")) { if (e.getMessage().contains(AUTHENTICATION_UNSUCCESSFUL) || e.getMessage().contains(WRONG_USERNAME_PASSWORD)) {
throw new BadRequestException("Authentication unsuccessful"); throw new BadRequestException(AUTHENTICATION_UNSUCCESSFUL);
} else { } else {
throw new BadRequestException(e.getMessage()); throw new BadRequestException(e.getMessage());
} }