Using security.checkpassword

hello all!

I am stuck on using t his function: security.checkPassword. I would like to incorporate it into the onaction of an icon on a form so only authorized individuals can use it. Here is the code sample:

//return true if the password for that userUID is correct, else false
if(security.checkPassword(security.getUserUID(), ‘password1’))
{
security.setPassword(security.getUserUID(), ‘password2’)
}
else
{
application.output(‘wrong password’)
}

What I have done is replaced the getUserUID and pw to:

//return true if the password for that userUID is correct, else false
if(security.checkPassword(security.getUserUID(BOB), ‘1234’))
{
security.setPassword(security.getUserUID(BOB), ‘1234’)
}
else
{
application.output(‘wrong password’)
}

This the error I get…
ReferenceError: “BOB” is not defined. (my_test_pass; line 4)

What am I doing wrong?

You get the error because BOB is not enclosed in quotes. If you want to check the password for userid BOB then you should probably do it like this:

//return true if the password for that userUID is correct, else false
if(security.checkPassword(‘BOB’), ‘1234’))
{
// green light to proceed - don’t set the password with a value it already has
}
else
{
application.output(‘wrong password’)
}