Hi,
How to override the session timeout alert message?
Now by default serenity throws the below message.
"The Provided anti-forgery was meant for user "username" but the current user is "" ".
How to override or change this text message?
And also how to prompt the user before session gets timed out?
can anyone please help me.
Hi @AmuthaKondusamy ,
how to override the message I don't know, but one way to display an alert before the session timeouts would be to do it like this https://stackoverflow.com/questions/23023916/javascript-auto-logout-code#answer-23024313:
(Generously borrowed from above page and copied here to stay in case the target page disappears):
// Set timeout variables.
var timoutWarning = 20 *60000; // Display warning in 20 Mins.
var timoutNow = 1 * 60000; // Warning has been shown, give the user 1 minute to interact
var logoutUrl = '/Account/Login/"'; // URL to logout page.
var warningTimer;
var timeoutTimer;
// Start warning timer.
function StartWarningTimer() {
warningTimer = setTimeout("IdleWarning()", timoutWarning);
}
// Reset timers.
function ResetTimeOutTimer() {
clearTimeout(timeoutTimer);
StartWarningTimer();
$("#timeout").dialog('close');
}
// Show idle timeout warning dialog.
function IdleWarning() {
clearTimeout(warningTimer);
timeoutTimer = setTimeout("IdleTimeout()", timoutNow);
$("#timeout").dialog({
modal: true
});
// Add code in the #timeout element to call ResetTimeOutTimer() if
// the "Stay Logged In" button is clicked
}
// Logout the user.
function IdleTimeout() {
window.location = logoutUrl;
}
Set the value of timeoutWarning to the same amount of time which you have configured within web.config.
Hope this helps.
With kind regards,
John
Hello
interesting article. It is a very sensitive problem for web applications.
you could better explain how it is implemented in serenity.
Thank you
@JohnRanger : setTimeout() is Page specific but I need it to be application specific
Can you please help me on that
Most helpful comment
Hi @AmuthaKondusamy ,
how to override the message I don't know, but one way to display an alert before the session timeouts would be to do it like this https://stackoverflow.com/questions/23023916/javascript-auto-logout-code#answer-23024313:
(Generously borrowed from above page and copied here to stay in case the target page disappears):
Set the value of timeoutWarning to the same amount of time which you have configured within web.config.
Hope this helps.
With kind regards,
John