mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Bug 14336 - Login API does not return UUID's
Changes done: - Provide UUID for userid and domainid only while constructing the login response. Session will hold the DB id's as before, to ensure other parts keep working. - This reverts commit de28aa3ddde5b601f2f234f2eccef871fbaf1a06.
This commit is contained in:
parent
a5d7cd3d51
commit
e43914ab58
@ -814,24 +814,24 @@ public class ApiServer implements HttpRequestHandler {
|
||||
Account account = _accountMgr.getAccount(userAcct.getAccountId());
|
||||
|
||||
// set the userId and account object for everyone
|
||||
session.setAttribute("userid", userAcct.getId());
|
||||
UserVO user = (UserVO) _accountMgr.getActiveUser(userAcct.getId());
|
||||
if(user.getUuid() != null){
|
||||
session.setAttribute("userid", user.getUuid());
|
||||
}
|
||||
else{
|
||||
session.setAttribute("userid", userAcct.getId());
|
||||
session.setAttribute("user_UUID", user.getUuid());
|
||||
}
|
||||
|
||||
session.setAttribute("username", userAcct.getUsername());
|
||||
session.setAttribute("firstname", userAcct.getFirstname());
|
||||
session.setAttribute("lastname", userAcct.getLastname());
|
||||
session.setAttribute("accountobj", account);
|
||||
session.setAttribute("account", account.getAccountName());
|
||||
|
||||
session.setAttribute("domainid", account.getDomainId());
|
||||
DomainVO domain = (DomainVO) _domainMgr.getDomain(account.getDomainId());
|
||||
if(domain.getUuid() != null){
|
||||
session.setAttribute("domainid", domain.getUuid());
|
||||
}else{
|
||||
session.setAttribute("domainid", account.getDomainId());
|
||||
session.setAttribute("domain_UUID", domain.getUuid());
|
||||
}
|
||||
|
||||
session.setAttribute("type", Short.valueOf(account.getType()).toString());
|
||||
session.setAttribute("registrationtoken", userAcct.getRegistrationToken());
|
||||
session.setAttribute("registered", new Boolean(userAcct.isRegistered()).toString());
|
||||
|
||||
@ -378,6 +378,13 @@ public class ApiServlet extends HttpServlet {
|
||||
private String getLoginSuccessResponse(HttpSession session, String responseType) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
int inactiveInterval = session.getMaxInactiveInterval();
|
||||
|
||||
String user_UUID = (String)session.getAttribute("user_UUID");
|
||||
session.removeAttribute("user_UUID");
|
||||
|
||||
String domain_UUID = (String)session.getAttribute("domain_UUID");
|
||||
session.removeAttribute("domain_UUID");
|
||||
|
||||
|
||||
if (BaseCmd.RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
|
||||
sb.append("{ \"loginresponse\" : { ");
|
||||
@ -386,9 +393,15 @@ public class ApiServlet extends HttpServlet {
|
||||
sb.append("\"timeout\" : \"" + inactiveInterval + "\"");
|
||||
while (attrNames.hasMoreElements()) {
|
||||
String attrName = (String) attrNames.nextElement();
|
||||
Object attrObj = session.getAttribute(attrName);
|
||||
if ((attrObj instanceof String) || (attrObj instanceof Long)) {
|
||||
sb.append(", \"" + attrName + "\" : \"" + attrObj.toString() + "\"");
|
||||
if("userid".equalsIgnoreCase(attrName)){
|
||||
sb.append(", \"" + attrName + "\" : \"" + user_UUID + "\"");
|
||||
}else if("domainid".equalsIgnoreCase(attrName)){
|
||||
sb.append(", \"" + attrName + "\" : \"" + domain_UUID + "\"");
|
||||
}else{
|
||||
Object attrObj = session.getAttribute(attrName);
|
||||
if ((attrObj instanceof String) || (attrObj instanceof Long)) {
|
||||
sb.append(", \"" + attrName + "\" : \"" + attrObj.toString() + "\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -400,9 +413,15 @@ public class ApiServlet extends HttpServlet {
|
||||
if (attrNames != null) {
|
||||
while (attrNames.hasMoreElements()) {
|
||||
String attrName = (String) attrNames.nextElement();
|
||||
Object attrObj = session.getAttribute(attrName);
|
||||
if (attrObj instanceof String || attrObj instanceof Long || attrObj instanceof Short) {
|
||||
sb.append("<" + attrName + ">" + attrObj.toString() + "</" + attrName + ">");
|
||||
if("userid".equalsIgnoreCase(attrName)){
|
||||
sb.append("<" + attrName + ">" + user_UUID + "</" + attrName + ">");
|
||||
}else if("domainid".equalsIgnoreCase(attrName)){
|
||||
sb.append("<" + attrName + ">" + domain_UUID + "</" + attrName + ">");
|
||||
}else{
|
||||
Object attrObj = session.getAttribute(attrName);
|
||||
if (attrObj instanceof String || attrObj instanceof Long || attrObj instanceof Short) {
|
||||
sb.append("<" + attrName + ">" + attrObj.toString() + "</" + attrName + ">");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user