Browse code

[ips] BM-11630 Fix: don't swallow login errors

Thomas Cataldo authored on 22/06/2017 12:58:48
Showing 1 changed files
... ...
@@ -60,10 +60,16 @@ public abstract class AbstractLoginCP extends AbstractProcessor {
60 60
 		IAuthenticationPromise authApi = anonProvider.instance("bm/core", IAuthenticationPromise.class);
61 61
 		CompletableFuture<LoginResponse> loginRespProm = authApi.login(login, password, "ips");
62 62
 
63
-		CompletableFuture<String[]> imapProm = vls.locate("mail/imap").exceptionally(t -> new String[] { "127.0.0.1" });
63
+		CompletableFuture<String[]> imapProm = vls.locate("mail/imap").exceptionally(t -> {
64
+			logger.error("Error locating mail/imap", t);
65
+			return new String[] { "127.0.0.1" };
66
+		});
64 67
 
65
-		loginRespProm.thenAccept(loginResp -> {
66
-			if (loginResp.status == LoginResponse.Status.Ok) {
68
+		loginRespProm.whenComplete((loginResp, loginEx) -> {
69
+			if (loginEx != null) {
70
+				logger.error("[{}] Login call failed", login, loginEx);
71
+				delayedDenial(authHandler);
72
+			} else if (loginResp.status == LoginResponse.Status.Ok) {
67 73
 				VertxPromiseServiceProvider apiProvider = new VertxPromiseServiceProvider(provider, vls,
68 74
 						loginResp.authKey);
69 75