Thanks, I thought there was a standard solution.
I tried this:
add this scrip to layout:
<script>
var time = new Date().getTime();
$(document.body).bind("mousemove keypress", function(e) {
time = new Date().getTime();
});
function refresh() {
if(new Date().getTime() - time >= 60000)
ajax("{{=URL('default', 'login_status')}}", [], ':eval')
else
setTimeout(refresh, 10000);
}
setTimeout(refresh, 10000);
</script>
and this function to the default controller.
def login_status():
if auth.user:
return '' # user is still logged in
else:
redirect(URL('default', 'index'), client_side=True)
The java script checks every 10 second for mouse activity: if there is 60 seconds no activity it will make an ajax call to see if the user is still logged in.
if not logged in it will redirect.
Unfortunately it doesn't work:
I hoped it worked but it seems that the ajax call keeps the user logged in.
Is it possible to read the time left from auth.settings.expiration ?