Security: Auto log out: Inactivity Period

Discussion of application development using iX Developer, including but not limited to getting started, using the functions tab, properties, objects and installation.
Post Reply
kkwon2
Posts: 26
Joined: Thu Dec 13, 2012 2:07 pm

Security: Auto log out: Inactivity Period

Post by kkwon2 »

Can the auto logout inactivity period be changed at runtime?

Lars
Posts: 5
Joined: Wed Mar 09, 2016 3:53 am

Re: Security: Auto log out: Inactivity Period

Post by Lars »

As fas as I know its not possible. But here's a small example how you can do your own log out function with your own tag for seconds before auto logout.
It uses the mouse position, and that works even if you dont have a mouse attached.

private static System.Windows.Forms.Timer _timer;
private int _mouseX = -1;
private int _mouseY = -1;
private int _mouseMoved;

private void TimerTick(Object sender, EventArgs e)
{
var x = System.Windows.Forms.Control.MousePosition.X;
var y = System.Windows.Forms.Control.MousePosition.Y;

if( ( Math.Abs(_mouseX-x) > 5 ) || ( Math.Abs(_mouseY-y) > 5 ) )
{
_mouseMoved=0;
}
else
{
_mouseMoved++;

var inactivityTimeout = Globals.Tags.System_InactivityTimeBeforeLogout.Value * 60;

if((inactivityTimeout>0) && (_mouseMoved > inactivityTimeout))
{
Globals.Security.Logout();
}
}
_mouseX = x;
_mouseY = y;
}

void Scriptmodule_Created(System.Object sender, System.EventArgs e)
{
// Set up timer that monitors if the mouse has moved
_timer = new System.Windows.Forms.Timer {Interval = 1000};
_timer.Tick += TimerTick;
_timer.Enabled = true;
}

Good luck :)

Post Reply