diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java index eec6f87e518..314a863c566 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java @@ -118,9 +118,12 @@ public class LoginHandler extends HttpServlet { apiRegEndpoint.setEntity(constructAppRegPayload(tags)); ProxyResponse clientAppResponse = HandlerUtil.execute(apiRegEndpoint); - String clientAppResult = clientAppResponse.getData(); - if (!StringUtils.isEmpty(clientAppResult) && getTokenAndPersistInSession(req, resp, + if (clientAppResponse.getCode() == HttpStatus.SC_UNAUTHORIZED){ + HandlerUtil.handleError(req, resp, serverUrl, platform, clientAppResponse); + return; + } + if (clientAppResponse.getCode() == HttpStatus.SC_CREATED && getTokenAndPersistInSession(req, resp, clientAppResponse.getData(), scopes)) { ProxyResponse proxyResponse = new ProxyResponse(); proxyResponse.setCode(HttpStatus.SC_OK); @@ -253,6 +256,8 @@ public class LoginHandler extends HttpServlet { private StringEntity constructAppRegPayload(JsonArray tags) { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty(HandlerConstants.APP_NAME_KEY, HandlerConstants.PUBLISHER_APPLICATION_NAME); + jsonObject.addProperty(HandlerConstants.USERNAME, username); + jsonObject.addProperty(HandlerConstants.PASSWORD, password); jsonObject.addProperty("isAllowedToAllDomains", "false"); jsonObject.add(HandlerConstants.TAGS_KEY, tags); String payload = jsonObject.toString(); diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java index 12a44905a28..562f497678f 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java @@ -31,6 +31,8 @@ public class HandlerConstants { public static final String SESSION_AUTH_DATA_KEY = "authInfo"; public static final String UI_CONFIG_KEY = "ui-config"; public static final String PLATFORM = "platform"; + public static final String USERNAME = "username"; + public static final String PASSWORD = "password"; public static final String DEFAULT_ERROR_CALLBACK = "/pages/error/default"; public static final String ERROR_CALLBACK_KEY = "errorCallback"; public static final String API_COMMON_CONTEXT = "/api";