<%@language = "javascript" %>
<% /*
     $Revision$
     $Id$
*/ %>

<%
var EXPIRED_PASSWORD_OK = true;
var JSON_Result = true;
%>

<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/json2.js" -->
<!-- #include file="../Shared/login.inc" -->

<%
protectRequest.validateToken();
var result = { success: true };
if (Session("org_user_key") > 0)
{
    var was_key = user_key;
    var other_key = parseInt(Session("org_user_key"), 10);
    var other_naam = user.naam();
    doLogin(other_key);
    var since = new Date(Session("org_user_key_ts"));
    result.message = L("lcl_impersonate_return").format(user.naam());
    shared.trackaction("PRSLOG", was_key, L("lcl_impersonated_end").format(toDateTimeString(since)));
    Session.Contents.Remove("org_user_key");
    Session.Contents.Remove("org_user_key_ts");
}
else
{
    doLogoff();
}
Response.Write(JSON.stringify(result));
Response.End;
%>