security.login returns false

Why isn’t this working in the authenticator solution? I’ve also tried just passing [‘group’] as the third argument.

hashCode = plugins.it2be_cryptor.SHA(password + fsUserInfo['usr_password_salt']);
if(hashCode == fsUserInfo['usr_password_hash']) {
	var aAccessLevel = new Array(1);
	aAccessLevel[0] = fsUserInfo['usr_privilege_level'];
	proceed_B = security.login(fsUserInfo['usr_user_name'],fsUserInfo['usr_user_info_id'],aAccessLevel);
		if(proceed_B == true) { ...

thanks,
Don

Why don’t you use SHAequals(…)

Hi Marcel,

That part works just fine. It’s the security.login which is returning false. Any theories on that?

Thank you,
Don

Are you sure the user name is correct?
What happens when you use the below code?
And, what happens when you use a hard coded user name?

proceed_B = security.login(fsUserInfo['usr_user_name']);
      if(proceed_B) { ...

Hi Marcel,

When I try either of those other ways, I get error messages (see attached).

When you say, “are you sure that the name is correct”, what do you mean? This is using database table authentication, so (I assume that) the security.login() call doesn’t know any user names yet – I’m letting the system know who is logging in.

Thank you,
Don

Look at the login method. It wants a user name, user id and a groups array.

Hi Patrick,

Those were the arguments being passed to security.login(), before the two tests above. It’s the line that is commented out. When I trace, I see the values. Is that what you mean?

Thank you,
Don

OK, the login(name) thing is my mistake.
Maybe you should use only hardcoded values at first (like you did in the 2nd sample) to see if that works.

Hi Marcel,

It still returns false (see attached). Any more thoughts on things to try? Perhaps there is something really obvious I’ve overlooked? I notice that the warning message says something about needing an object rather than a string argument.

Thank you,
Don

When ‘Designer’ is the display name and the uuid and groups are correct I don’t see why this would fail.

I did notice though that the tooltip says that the uuid must be an Object.
A String value is an Object as well so I guess this only means that you can use different data types.

Hi Marcel,

What do you mean by “correct” – is the command checking against some other reference before it returns true? What would cause this command to return false instead of true?

Thank you,
Don

Reading the wiki (http://wiki.servoy.com/display/public/D … 50467C42ED) I would say that the user, uuid and groups have to exist within Servoy.
To be honest, I have not used this method yet so I am not sure…

Hi Marcel,

I’m getting a “server not found” for the Servoy Wiki right now. I have read the discussion of custom login solutions a few times now, and I think that I remember most of it. I also (loosely) based my login solution code on the servoy_security solution.

I thought that the purpose of the security.login command in the authentication method was for Servoy to move the user from the login page to the first form of the solution itself. The developer is responsible for any validation of the user name and password, prior to calling security.login(). So what additional validation would this command perform?

Is anyone else using security.login() with a custom authentication method?

Thank you,
Don

I only have a test user on my server and that fails as well with the authentication and login to be honest…
That is why I (also) think that the user has to be know in Servoy (like in older security setup).

Hi Marcel,

I also tried the following, thinking that maybe Servoy needs to have the user listed in its own internal db,

var returnUID = security.createUser(fsUserInfo['usr_user_name'],fsUserInfo['usr_password_hash'],fsUserInfo['usr_user_info_id'])
proceed_B = security.login(fsUserInfo['usr_user_name'], fsUserInfo['usr_user_info_id'], ['']);

However, it still returns proceed_B as false.

Is there anyone out there that is using custom authentication?

Thank you,
Don

Don,

security.login requires a non-null, non-empty array of strings as group names, all these groups have to exist.
Your code uses group Administrator, does this group exist?
Maybe it is a typo, Servoy comes with a standard group called Administrators.

When security.login fails because of unknown group, you should see a message in the log file like:
Could not log in user for unknown group ‘Administrator’"

Rob

Hi Rob,

That solved the problem. Because I’m doing custom security, I didn’t realize that I still needed to create the users and groups in the structure of the program (“User/Group Editor”). I thought that I would manage this completely on my own with the data tables, and that Servoy would simply pass back the user UID I would give it, to the onSolutionOpen method in the main application.

Thanks very much, this issue had been a hindrance for some time.

Don