Merge branch 'application-mgt-new' into 'application-mgt-new'

Fix APPM login issue

See merge request entgra/carbon-device-mgt!293
4.x.x
Dharmakeerthi Lasantha 5 years ago
commit 594ab3ed60

@ -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();

@ -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";

Loading…
Cancel
Save