<!--KIOSK MODE LOGIC-->

~[tlist_sql;
    select
        U_IDENTIMETRICS_ATT_FOTM_USER.usersdcid,
        U_IDENTIMETRICS_ATT_FOTM_USER.forcelogoff
    from
        U_IDENTIMETRICS_ATT_FOTM_USER
    where
        U_IDENTIMETRICS_ATT_FOTM_USER.usersdcid = ~[x:users_dcid]
        and U_IDENTIMETRICS_ATT_FOTM_USER.kioskUser = 1
;]
    <script>
        console.log("~(usersdcid;json)")
        if ("~(forcelogoff;json)" == "1") {
            //Need to change the log off flag...
            loadingDialog()
            $j.get("/admin/attendance/functions/idm_helper.html?helperType=userAuth&frn=204~(usersdcid;json)&forceLogOff=1").then(function(response) {
                let form = $j(response).filter("input")
                $j(form).filter("#forceLogOff").val("0")
                let params = $j(form).serialize()
                $j.get(`/admin/attendance/functions/idm_helper.html?${params}`).then(function() {
                    $j.get("/admin/~loff").then(function() {
                        window.location = "/admin/pw.html"
                    })
                })
            })
        } else {
            if (window.location.href.includes("/idm_scanKiosk.html")) {
                history.pushState(null, document.title, location.href)
                window.addEventListener('popstate', function (event) {
                    history.pushState(null, document.title, location.href)
    
                    if (document.getElementById("studentIdentifier")) {
                        document.getElementById("studentIdentifier").focus()
                    }
                })
            } else {
                window.location = "/admin/attendance/functions/idm_scanKiosk.html"
            }
        }
    </script>
[/tlist_sql]