Using security.checkpassword

Questions, tips and tricks and techniques for scripting in Servoy

Using security.checkpassword

Postby Detox » Tue Jul 19, 2011 5:39 am

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?
Detox
 
Posts: 73
Joined: Wed Dec 13, 2006 11:02 pm

Re: Using security.checkpassword

Postby omar » Tue Jul 19, 2011 11:24 am

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')
}
omar
 
Posts: 377
Joined: Sat Feb 12, 2011 4:51 pm
Location: Intrasoft, The Netherlands


Return to Methods

Who is online

Users browsing this forum: No registered users and 20 guests

cron