Manchmal möchte man im Frontend prüfen, ob die fe_user-Session des Benutzers noch gültig ist und dann automatisch ausloggen. Das ist vor allem beim Single-Page-Applications (SPA) sehr hilfreich.
TypoScript Setup:
plugin.tx_myextension.settings {
pidLogout = 344
}
logincheck = PAGE
logincheck {
typeNum = 7780
config {
disableAllHeaderCode = 1
xhtml_cleaning = 0
admPanel = 0
additionalHeaders = Content-type: text/plain
no_cache = 1
contentObjectExceptionHandler = 0
}
10 = COA_INT
10 {
20 = FLUIDTEMPLATE
20.template = TEXT
20.template.value = "login":{f:security.ifAuthenticated(then:1, else:0)},"redirect":"{f:security.ifAuthenticated(else:'{f:uri.page(pageUid:settings.pidLogout)}')}"
20.settings < plugin.tx_myextension.settings
stdWrap.wrap = {|}
}
}
JavaScript (jQuery). page-id anpassen!
$(function() {
setInterval( function () {
$.getJSON('index.php?id=XXX&type=7780').done(function ( data ) {
if (!data.login) {
window.location = data.redirect;
}
});
}, 10 * 1000);
});