<%
var log = new Log();
var cookie = request.getParameter("cookie");
var user = request.getParameter("user");
getUser();
function getUser(){

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


 try{

var oauthAdminClient = require('controllers/my_auth_apps/oauthAdminClient.jag');
var fieldValues = oauthAdminClient.getAppsAuthorizedByUser();

print( fieldValues );
    } catch(e) {
     print(getErrorMessage(e.message));
    }

}

function getErrorMessage(message) {
    if (message != null && message.length > 0) {
        if (message.indexOf('401 Error: Unauthorized') > -1) {
            return '{"success":false, "reLogin":true}';
        } else {
            var msg = message.split(':');
            if (msg.length > 0) {
                return '{"success":false, "message":"' + msg[1] + '"}';
            }
        }
    }
    return '{"success":false, "message":null}';
}

%>
