<%
include("../../util/constants.jag")
include("../../util/utility.jag")
var log = new Log();
var cookie = request.getParameter("cookie");
var carbon = require("carbon");
var user = request.getParameter("user");
var tenantUser = carbon.server.tenantUser(user);

session.put('auth-cookie', cookie);
session.put('user', user);

try {

    var serverCoreUrl = application.get(SERVER_CORE_URL);
    var url  = serverCoreUrl + "/t/" + tenantUser.domain + USERINFO_API_URI;
    var header = {"cookie" : cookie};
    var userInfoJSON = get(url, {}, header ,"json");
    validateResponse(userInfoJSON);

    response.contentType = 'application/json';
    print(userInfoJSON.data);

    } catch(e) {
        log.error(e.message);
        response.sendRedirect("/portal/error_pages/error.jag");
    }

%>
