function requestUI()

in Modules/device-path.js [190:212]


function requestUI(event, callback){
    //Retrieving the OIDC authenticated user attributes set by ALB
    var payload = common.base64UrlDecode(event.headers["x-amzn-oidc-data"].split('.')[1]);

    //Reading the HTML page
    fs.readFile('Resources/index.html', 'utf8', function(err, data) {
        if (err) {
            //There was an error reading the page, returning an HTML error
            console.log("Error reading Resources/index.html");
            console.log(err, err.stack);
            common.returnHTMLError(500, "", callback);
        } else {
            console.log("Success reading Resources/index.html " + data);
            //Sucessful, returning page and setting the username correctly
            var response = {
                statusCode: 200,
                headers: {"content-type": "text/html", "cache-control": "no-store"},
                body: data.replace("$Username", JSON.parse(payload).username)
            };
            callback(null, response);
        }
    });
}