Serenity: Session Timeout Alert

Created on 13 Apr 2018  路  3Comments  路  Source: serenity-is/Serenity

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.

community-support question

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 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

All 3 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chintankukadiya18 picture chintankukadiya18  路  3Comments

Shraddha996 picture Shraddha996  路  3Comments

ga5tan picture ga5tan  路  3Comments

Pinellus picture Pinellus  路  3Comments

Akarsh03 picture Akarsh03  路  3Comments