Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

Warning for automatic logout

Does anybody know of a modification that would display a warning to a staff user that they are about to be automatically logged out due to inactivity?

Right now it logs people out without any notification or redirect to the login page. That can be very annoying if you think you're logged in, and type a detailed reply for a ticket only to have it fail when you try to post it.
Tagged:

Comments

  • edited December 2014
    Oooook, i got a headache now but I played arround with it.

    So there are a few possibilities here.
    First i tried just to get an alert message saying 
    "Warning!
    You are going to be logged out in 30 Seconds due to inactivity"

    Is this enough for you? 
    Because I also thought about automatic reloading of the current ticket, so the user would never be logged out as long as the browser window is opened.
    There is just one minor problem with this idea, because sometimes ( I think as long as the draft has not been saved since the last change was made) the page will not allow an automatic reload due to the chance of data being lost. There will be an alert asking the user if he/she really wants to reload the page.
    If the User does not react the page will not reload an the user will be logged out. At least he/she will be redirected to the login page after clicking "ok" in the alert.

    Your Opinion?

    EDIT: Urgh, wrong Version, tested with 1.9.4, not 1.8.x
    Need to check in correct version, sorry!
  • Since we have not set a inactivity timeout, I can't tell if osTicket 1.9.4 behaves better then 1.8.x, but hopefully @Suntas can offer you a solution @SightTech since there is no built-in solution in osTicket.

    When you find a nice solution that works with 1.9.4 by altering the osTicket code and is worth to be included into the core of osTicket, make a pull request over at the github repo: https://github.com/osTicket/osTicket-1.8
  • @Suntas I think that solution would work very well as a stopgap measure. It prevents the user from thinking they're still logged in when they're not, which is really the heart of the issue.
    Would you mind posting the code here?
    I'll try it with osTicket 1.8 and report back.
  • edited December 2014
    Heyho, it's a quite simple jquery script.
    staff.inc.php (106)
    Right after

    $ost->addExtraHeader('<meta name="csrf_token" content="'.$ost->getCSRFToken().'" />');

    insert

    $ost->addExtraHeader('<script>
    $(\'document\').ready(function(){
    var timeoutTime = ' . $cfg->getStaffTimeout() .';
    if(timeoutTime > 0 ){
    setTimeout(function() {
    alert(\'Warning!\nYou are going to be logged out in 30 Seconds due to inactivity\');
    //window.onbeforeunload = null;
    //location.reload();
    }, (timeoutTime - 30)*1000);
    }
    });
    </script>');

     this adds a new script to the header when logged into the staff area.
    Right now this throws an alert window 30 seconds before the user gets logged out.
    As you can see i also played around with the automatic reloading, but it's... not very robust.

    And yes, this script should work fine in 1.8.x, but i wasn't sure how the code looked 0.1 version back ;)
  • I have tried this script and verified that it does work with osTicket 1.8, and I think that it should work with just about any version as long as the variables/functions are the same.

    Thanks a million @Suntas!

    As a side note to anyone wanting to use @Suntas's fix, please remember to uncomment "//window.onbeforeunload = null;" & "//location.reload();" if you want the page to refresh when the staff member clicks ok.
Sign In or Register to comment.