#include "get_cookie.h"
#include <saas/deploy_manager/server/client/client.h>

namespace NRTYDeploy {
    bool TScriptGetCookie::Process(IDeployInfoRequest& request) {
        TString user = request.GetRD().CgiParam.Get("user");
        if (!user)
            throw yexception() << "user not set";
        TString cookie = request.GetUserAccessControl().GetCookie(user);
        request.Output() << "HTTP/1.1 200 Ok\r\n\r\n";
        request.Output() << "{\"cookie\" : \"" << cookie << "\"}";
        return true;
    }

    TScriptGetCookie::TFactory::TRegistrator<TScriptGetCookie> TScriptGetCookie::Registrator("get_cookie");
}
