# Security Question

**URL:** <https://forum.inductiveautomation.com/t/security-question/1755>\
**Category:** Ignition\
**Created:** [April 14, 2010, 2:47pm UTC](https://forum.inductiveautomation.com/t/security-question/1755 "2010-04-14T14:47:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![JasonFraser](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@JasonFraser](https://forum.inductiveautomation.com/u/JasonFraser)\
**Post date:** [April 14, 2010, 2:47pm UTC](https://forum.inductiveautomation.com/t/security-question/1755/1 "2010-04-14T14:47:49Z")

</div>

Hello,  
I am using the auto login function with a standard view only user profile. Basically what I am trying to to is allow anyone to view the project but only allow authorized users to make changes. the idea is if the user wants to push buttons or enter information into a text field, the user has to log in to do so. After a certain amount of time (15 min), the user is logged out, and the view only profile is logged back in. I have a logout button and it works well enough, i am thinking of using a client event script for the 15 min. user login. My confusion is whether to use the timer script ( makes sense ) or a tag change script. I pretty sure that i want to point the script to the client.system.user tag to accomplish this. Any suggestions would be helpful. I am still exploring this on my own.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 14, 2010, 4:04pm UTC](https://forum.inductiveautomation.com/t/security-question/1755/2 "2010-04-14T16:04:56Z")

</div>

For this you want to use a Client Event Timer Script under Project -\> Client Event Scripts. You can run the timer script every minute or so checking for the number of seconds since any keyboard or mouse activity happens. Your function will look like this:

`seconds = system.util.getInactivitySeconds()
if seconds == 900: # 15 minutes
  system.security.switchUser('guest', 'guest')`  
Hope this helps.

---

<div class="post-metadata">

**Author:** ![JasonFraser](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@JasonFraser](https://forum.inductiveautomation.com/u/JasonFraser)\
**Post date:** [April 14, 2010, 4:49pm UTC](https://forum.inductiveautomation.com/t/security-question/1755/3 "2010-04-14T16:49:00Z")

</div>

Travis,  
Yes that’s about what I was thinking although I was a little confused on which route to take.  
I will try this out. Thanks!

---

<div class="post-metadata">

**Author:** ![JasonFraser](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@JasonFraser](https://forum.inductiveautomation.com/u/JasonFraser)\
**Post date:** [April 14, 2010, 6:01pm UTC](https://forum.inductiveautomation.com/t/security-question/1755/4 "2010-04-14T18:01:57Z")

</div>

Travis,  
I tried the script and it doesn’t seem to be working. I put it in the client event scripts under the configuration section in the Designer. I set the delay to 120,000 ms the delay type to fixed rate and the thread option s to run in shared. I then entered the script in as follows:  
seconds = system.util.getInactivitySeconds()  
if seconds == 120:  
system.security.switchUser(‘view only’, ‘password’)

I set the time to 120 seconds so I didn’t have to wait every 15 min to see if it works. I also tested by adding a button and entering the last script line in the event handler. it works when I push the button. What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 14, 2010, 6:30pm UTC](https://forum.inductiveautomation.com/t/security-question/1755/5 "2010-04-14T18:30:35Z")

</div>

You have to test it out in the client by leaving the client alone for two minutes. You can add a print statement in the script to see if it is runnning:`print "here"`That print out will show in the console under Help-\>Diagnostics in the client.

---

<div class="post-metadata">

**Author:** ![JasonFraser](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@JasonFraser](https://forum.inductiveautomation.com/u/JasonFraser)\
**Post date:** [April 14, 2010, 7:32pm UTC](https://forum.inductiveautomation.com/t/security-question/1755/6 "2010-04-14T19:32:31Z")

</div>

It’s working now, had a couple spaces instead of using a tab.  
thanks again guys.

---

<div class="post-metadata">

**Author:** ![Kevin.McClusky](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@Kevin.McClusky](https://forum.inductiveautomation.com/u/Kevin.McClusky)\
**Post date:** [April 14, 2010, 8:26pm UTC](https://forum.inductiveautomation.com/t/security-question/1755/7 "2010-04-14T20:26:42Z")

</div>

May I suggest changing the “==” to a “\>=”? If it misses that execution at 900 seconds, it may never log out.

if seconds == 900:

to something like

if user != “guest” and seconds \>= 900:

Note: you’d have to get the variable user. (Which is easy to do, but I don’t remember how to off the top of my head)

Cheers

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [April 14, 2010, 9:41pm UTC](https://forum.inductiveautomation.com/t/security-question/1755/8 "2010-04-14T21:41:11Z")

</div>

Kevin - excellent points.
