diff --git a/portals/publisher/src/main/java/org/wso2/carbon/apimgt/ui/publisher/Util.java b/portals/publisher/src/main/java/org/wso2/carbon/apimgt/ui/publisher/Util.java
index e9494698432..cf06a30fd89 100644
--- a/portals/publisher/src/main/java/org/wso2/carbon/apimgt/ui/publisher/Util.java
+++ b/portals/publisher/src/main/java/org/wso2/carbon/apimgt/ui/publisher/Util.java
@@ -149,6 +149,15 @@ public static String getServiceProviderTenantDomain(HttpServletRequest request)
}
}
+ public static boolean isEnableEmailUserName() {
+ boolean isEnableEmailUserName = Boolean.parseBoolean(CarbonUtils.getServerConfiguration().getFirstProperty("EnableEmailUserName"));
+ if (isEnableEmailUserName) {
+ return isEnableEmailUserName;
+ } else {
+ return false;
+ }
+ }
+
/**
* Deciding what to process as app context.
* If the settings.json has the following definition,
diff --git a/portals/publisher/src/main/webapp/services/login/introspect.jsp b/portals/publisher/src/main/webapp/services/login/introspect.jsp
index 883176196ad..214cb3df9d1 100644
--- a/portals/publisher/src/main/webapp/services/login/introspect.jsp
+++ b/portals/publisher/src/main/webapp/services/login/introspect.jsp
@@ -73,7 +73,15 @@
log.debug("Introspection result json: " + introspectResult.body());
if (introspectResult.statusCode() == 200) {
+ boolean isEnableEmailUserName = Util.isEnableEmailUserName();
Map introspect = gson.fromJson(introspectResult.body(), Map.class);
+ String username = (String) introspect.get("username");
+ Pattern regPattern = Pattern.compile("(@)");
+ boolean found = regPattern.matcher(username).find();
+ int count = !found ? 0 : (int) username.chars().filter(ch -> ch == '@').count();
+ if (isEnableEmailUserName || (username.indexOf("@carbon.super") > 0 && count <= 1)) {
+ introspect.put("username", username.replace("@carbon.super", ""));
+ }
response.setContentType("application/json");
out.println(gson.toJson(introspect));
} else {