RED-6903 - Adjust failure message
This commit is contained in:
parent
9ace6e25a5
commit
57aa00e096
@ -33,6 +33,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@RequiredArgsConstructor
|
||||
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) {
|
||||
|
||||
@ -121,8 +123,8 @@ public class EmailService {
|
||||
return SMTPResponse.builder()
|
||||
.statusCode(200);
|
||||
} catch (Exception e) {
|
||||
if (e.getMessage().contains("Authentication unsuccessful, the user credentials were incorrect")) {
|
||||
throw new BadRequestException("Authentication unsuccessful");
|
||||
if (e.getMessage().contains(AUTHENTICATION_UNSUCCESSFUL) || e.getMessage().contains(WRONG_USERNAME_PASSWORD)) {
|
||||
throw new BadRequestException(AUTHENTICATION_UNSUCCESSFUL);
|
||||
} else {
|
||||
throw new BadRequestException(e.getMessage());
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user