Please help with API way of checking UserID and Password
Barry G. Sumpter
barrysum at bigpond.net.au
Mon Mar 26 17:32:51 CDT 2012
Hi all,
I'm not sure if this is the correct way to verify UserID and Passoword using
API.
This is the only example I could find with two fields.
I'm used to the SQL way so the API way is a little strange to me.
>From v4Rev example Field_Find.rev
We do a Find Field based on a user name
Then do a find field based on a password
Then do a vset_intersect between the two results- that I can't get to work
Is there a better way?
Why is my vset_intersect returning the - fatal signal 11 error which is
usually a wrong object being used.
I'm removed a lot of debugging messages.
This is the real meat of the script.
I've had a really good look at vWiki but nothing looks close to the LiveCode
script found in the v4Rev samples.
Any help would be greatly appreciated.
tia
----
on ValidateUsernameAndPassword
initValentinaDB_AsLocalOrRemoteServer
-- setup Database Object
initValentinaDB_OpenConnectionLocalOrRemoteServer -- setup DB
Connection Object
initValentinaDB_OpenOrCreate
-- setup Table and Fields Object
-- Put "--Starting - SelectAll" & cr
-- put VTable_SelectAllRecords( mGeoUser ) into allRecs -- this works
returns all 10 recs
-- get showError()
-- ShowSet mGeoUser, allRecs
put VField_FindValue( mUsername, gMyUsername ) into set1 --create a
dataset of records that have this username -- Works - returns 1 rec
-- put VField_FindRange( mUsername, true, gMyUsername, gMyUsername, true
) into set1 -- Works -- returns 1 rec
put VSet_Count(set1) into recount -- must do this here else: Fatal
signal 11(usually wrong object) Don't know why
ShowSet mGeoUser, set1
if recCount < 1 then
put recCount & " ***** Valid Username not found: " & gMyUsername & "
- " & mUserName
end if
put "mPassword: " & mPassword & " - gMyPassword: " & gMyPassword & cr
put VField_FindValue( mPassword, gMyPassword ) into set2 --create a
dataset of records that have this password -- works returns 1 rec
-- put VField_FindRange( mPassword, true, gMyPassword, gMyPassword, true
) into set2 -- works returns 1 rec
put VSet_Count(set2) into recount -- must do this here else: Fatal
signal 11(usually wrong object) Don't know why
ShowSet mGeoUser, set2
if recCount < 1 then
put recCount & " ***** Valid Password not found: " & gMyPassword & "
- " & mPassword
end if
-- Now combine the two RecID Datasets - should only have 1 record - if
two then there a duplicate UID/PW combo recs
put VSet_Intersection( set1, set2) into set3 -- I get a fatal signal 11
here - (usually using the wrong object) ************
put VSet_Count(set3) into recount -- must do this here else: Fatal
signal 11(usually wrong object) Don't know why
ShowSet mGeoUser, set3
if recCount < 1 then
put recCount & " ***** Valid Username and Password combination not
found: " & gMyPassword & " - " & mPassword
end if
--Always get error on these destructors: livecode-server exited due to
fatal signal 11
-- put VSet_Destructor(set1) into set1
-- put VSet_Destructor(set2) into set2
end ValidateUsernameAndPassword
More information about the Valentina
mailing list