# Using password field to make a button visible?

**URL:** <https://forum.inductiveautomation.com/t/using-password-field-to-make-a-button-visible/76598>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [July 19, 2023, 6:41pm UTC](https://forum.inductiveautomation.com/t/using-password-field-to-make-a-button-visible/76598 "2023-07-19T18:41:10Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![rdickinson](https://avatars.discourse-cdn.com/v4/letter/r/bc8723/32.png) [@rdickinson](https://forum.inductiveautomation.com/u/rdickinson)\
**Post date:** [July 19, 2023, 6:41pm UTC](https://forum.inductiveautomation.com/t/using-password-field-to-make-a-button-visible/76598/1 "2023-07-19T18:41:10Z")

</div>

I'm fairly new to Ignition.

In Vision I want to use a "password field". Once the password is entered a "toggle button" is then visible.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/9/99c9d3e7b26600dc89732d82c722a0eb612d516f.png)

Needless to say, I didn't get very far. 😊

Thanks for any help! 🙂

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 19, 2023, 6:50pm UTC](https://forum.inductiveautomation.com/t/using-password-field-to-make-a-button-visible/76598/2 "2023-07-19T18:50:52Z")

</div>

In the simplest form, you would bind the 'Visibility' property of the toggle button to an expression that compares the value in the password field with your known static password.

---

<div class="post-metadata">

**Author:** ![grsimpson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/grsimpson/32/49953_2.png) [@grsimpson](https://forum.inductiveautomation.com/u/grsimpson)\
**Post date:** [July 19, 2023, 11:06pm UTC](https://forum.inductiveautomation.com/t/using-password-field-to-make-a-button-visible/76598/3 "2023-07-19T23:06:42Z")

</div>

Another option, instead of storing a password in your project (not a very secure method), is to use an expression binding on the visibility property that checks the length of the entered password, and if the password length is greater than X the button will be visible. Change it to the length of your password or use some other value, up to you.

This expression, on the visible property of the button, will enable the button visibility as long as 1 character has been entered in the password field.

```auto
if(len({Root Container.Password Field.text})>0, 1, 0)

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 19, 2023, 11:27pm UTC](https://forum.inductiveautomation.com/t/using-password-field-to-make-a-button-visible/76598/4 "2023-07-19T23:27:49Z")

</div>

> [@grsimpson](#):
>
> and if the password length is greater than X the button will be visible

How is that in any way more secure than to have a static password?

---

<div class="post-metadata">

**Author:** ![grsimpson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/grsimpson/32/49953_2.png) [@grsimpson](https://forum.inductiveautomation.com/u/grsimpson)\
**Post date:** [July 19, 2023, 11:45pm UTC](https://forum.inductiveautomation.com/t/using-password-field-to-make-a-button-visible/76598/5 "2023-07-19T23:45:55Z")

</div>

Because storing a static password, as Paul suggested, in the project to compare against the entered password is not secure.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 20, 2023, 12:00am UTC](https://forum.inductiveautomation.com/t/using-password-field-to-make-a-button-visible/76598/6 "2023-07-20T00:00:02Z")

</div>

More secure than _ **NO** _ password. Sheesh.

---

<div class="post-metadata">

**Author:** ![grsimpson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/grsimpson/32/49953_2.png) [@grsimpson](https://forum.inductiveautomation.com/u/grsimpson)\
**Post date:** [July 20, 2023, 12:04am UTC](https://forum.inductiveautomation.com/t/using-password-field-to-make-a-button-visible/76598/7 "2023-07-20T00:04:29Z")

</div>

Now you are putting words into my mouth...

Obviously you would use a password to authenticate the user, but the smart approach would be to take the entered password and verify the user with system.security.validateUser(). I am just offering a solution to enabling the visibility of the button.

The reason why comparing a static password saved into the project isn't a good idea, is because a user that doesn't have access to editing the project will have access to the .ignition cache on their local machine after launching said project. The .proj file found in the cache could then be restored to another gateway, opened in the designer, and the password is then compromised, if they aren't supposed to have it.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 20, 2023, 12:40am UTC](https://forum.inductiveautomation.com/t/using-password-field-to-make-a-button-visible/76598/8 "2023-07-20T00:40:09Z")

</div>

The _most correct_ thing to do is absolutely not to hardcode a password string, nor any information about the password. Instead, you should just attempt to authenticate the user with whatever password (e.g. with `system.security.switchUser`, and then rely on [component security](https://docs.inductiveautomation.com/display/DOC81/Component+and+Window+Security) to control component visibility. Attempting to 'pre-validate' the user is just begging for problems with out-of-sync auth.

---

<div class="post-metadata">

**Author:** ![rdickinson](https://avatars.discourse-cdn.com/v4/letter/r/bc8723/32.png) [@rdickinson](https://forum.inductiveautomation.com/u/rdickinson)\
**Post date:** [July 20, 2023, 6:27pm UTC](https://forum.inductiveautomation.com/t/using-password-field-to-make-a-button-visible/76598/9 "2023-07-20T18:27:34Z")

</div>

This is a very low security risk. Just to allow access to reset hours. So, I am just going to use an expression as PGriffith suggested.

Thanks Guys! 🙂
