Jump to content

Passing parameters to passwordVerify


Dreft

Recommended Posts

Im using async version of the function passVerify. How to pass some parameters to callback which is called after passVerify function completes?

As for now I have:

function someFunction()
	passwordVerify( password, hashedPassword, {}, passVerificationComplete )
end

function passVerificationComplete(matched)
	if matched then
		-- passwords matched
	else
		-- passwords mismatch
	end
end

in "passVerificationComplete" parameter "matched" is the value which is true or false, depends on what passwordVerify returned, how to pass some other parameters to passVerificationComplete callback? Something like this:

function someFunction()
	passwordVerify( password, hashedPassword, {}, passVerificationComplete(someOtherParam) )
end

function passVerificationComplete(matched, someOtherParam)
	if matched then
    	outputDebugString(someOtherParam)
		-- passwords matched
	else
		-- passwords mismatch
	end
end

 

Link to comment

This is the first idea that came to my mind, maybe is there more useful ways to do it.

function someFunction()
	passwordVerify( password, hashedPassword, {}, function(matched) passVerificationComplete(matched, someOtherParam) end )
end

function passVerificationComplete(matched, someOtherParam)
	if matched then
    	outputDebugString(someOtherParam)
		-- passwords matched
	else
		-- passwords mismatch
	end
end

 

  • Like 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...