var revoke_session_buttons = document.querySelectorAll('a[data-action="revoke-session"]');
if (revoke_session_buttons != null) {
    revoke_session_buttons.forEach(function (revoke_session_button) {
        revoke_session_button.addEventListener('click', (e) => {
            e.preventDefault();
            var id = e.currentTarget.getAttribute("data-id");
            CustomAlert({
                title: "Revoke Session",
                message: "Are you sure you want to revoke this session?",
                type: "question",
                close: true,
                showCancelButton: true,
                showCloseButton: true,
                showConfirmButton: true,
                cancelButtonText: 'Cancel',
                confirmButtonText: 'Confirm',
                static: false
            }).then((result) => {
                if (result.value === true) {
                    window.location.href = "/account/revoke-session?id=" + id + "&returnUrl=" + window.location.pathname;
                }
            });
        });
    });
}

var disable_otp_btn = document.querySelector('a[data-action="disable-otp"]');
if (disable_otp_btn != null) {
    disable_otp_btn.addEventListener('click', (e) => {
        e.preventDefault();
        CustomAlert({
            title: "Disable Two-Factor Authentication",
            message: "Are you sure you want to disable two-factor authentication?",
            type: "question",
            close: true,
            showCancelButton: true,
            showCloseButton: true,
            showConfirmButton: true,
            cancelButtonText: 'Cancel',
            confirmButtonText: 'Confirm',
            static: false
        }).then((result) => {
            if (result.value === true) {
                window.location.href = "/account/disable-otp?returnUrl=" + window.location.pathname;
            }
        });
    });
}