Troubleshooting security.login?

I’ve got a solution with custom login code. It all works great locally in developer, but when I get it on my server “security.login” is returning false.

I can’t figure out why. No errors thrown or logged.

I’ve added debugging code and can confirm than the right values are getting passed to security.login – but it just fails silently on the server.

What should I look for to test this further?

greg.

Anything in the log?
Can you share the code?

Nothing in the log. Code below.

It tries built-in Servoy users first, and that works on both developer and on the test server. On the test server, the built-in users also work, but the db users fail. The code makes it through to the “security.login” call, and calls it but it returns false.

Not sure what else to look for.

        var userId = security.getUserId(login);
	var ok = false;
	var groups = [];
	
	if(userId)
	{
		var ok = security.checkPassword(userId, password);
		var groups = [];
		if(ok)
			groups = security.getUserGroups(userId).getColumnAsArray(2);
	}
	if(!ok) // try user logins
	{
		var q = "SELECT user_id FROM users WHERE user_login = ?";
		var fs = databaseManager.getFoundSet('cfbs','users');
		fs.loadRecords(q, [login]);
		
		if(fs.getSize()==1)
		{
			var user = fs.getRecord(1);
			if(user.is_active != 1)
			{
				application.beep();
				errMsg = 'Login disabled.';
				return;
			}
			if(globals.security_hashPassword(password) != user.user_password)
			{
				application.beep();
				errMsg = 'Invalid password.';
				return;
			}
			userId = user.user_login;
			for(var ix=1; ix<=user.users_to_user_groups.getSize(); ix++)
			{
				var ug = user.users_to_user_groups.getRecord(ix);
				groups.push(ug.group_name);
			}
			ok = true;
		}
		else
		{
			errMsg = 'Login not found.';
			return;
		}	
	}
	
	if(!ok)
	{
		errMsg = 'Invalid login/password';
		return;
	}
	errMsg = '';	
	globals.dialog_info(login + "|" + userId + "|" + groups);
	if(!security.login(login, userId, groups))
		errMsg = 'Error logging in, please try again';
	else
	{
		application.output("LOGIN: " + login + "|" + userId + "|" + groups);	
		globals.cfbs_model_currentuser_login = login;
	}

The code makes it through to the “security.login” call, and calls it but it returns false.

Maybe I misinterpret what I am doing but the above makes sense to me.
The user does not exist so it returns false.

All groups in the array must exist in order for login to succeed, otherwise the method will return false. Maybe this is the problem ?

No, all the groups exists. I’ve tried with a user with no groups (just passing the empty array) and that fails, too.

greg.

This also fails if one parameter is null or empty, if group does not exist or if user uuid does not exist. Else an exception should be in the log.