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);
});
Vielen Dank … das hat mir bei einem Problem schonmal sehr weitergeholfen.
Wie kann ich eigentlich über eine eigene Extension in TYPO3 10 einen User einloggen?
Gibt es da auch ein gutes Tutorial zu?
Nach einem Update auf 10.4.14 funktioniert es auf einmal nicht mehr. Mal debuggen und schauen, wo da das Problem ist.
Also, bei mir funktionierte es bei TYPO3 11.5 einwandfrei.
Auch bei TYPO3 Version 12 funktioniert es so jetzt bei mir.
wird das auch noch für 13 funktionieren?
Bin gerade dabei meine erste T3 Seite zu bauen.
Besser ist es mit dem eId-Mechanismus.