# Why does security.login() always return false?

**URL:** <https://forum.servoy.com/t/why-does-security-login-always-return-false/14959>\
**Category:** Classic Servoy\
**Created:** [November 1, 2011, 5:02pm UTC](https://forum.servoy.com/t/why-does-security-login-always-return-false/14959 "2011-11-01T17:02:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlanBourke](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@AlanBourke](https://forum.servoy.com/u/AlanBourke)\
**Post date:** [November 1, 2011, 5:02pm UTC](https://forum.servoy.com/t/why-does-security-login-always-return-false/14959/1 "2011-11-01T17:02:37Z")

</div>

Here’s my authenticator solution code (not using Servoy tables for users etc).

I’ve read [http://wiki.servoy.com/display/public/DOCS/Implementing+Security](http://wiki.servoy.com/display/public/DOCS/Implementing+Security) quite a few times!

```auto
function Authenticate(userName, password) 
{

	var ret = false;
	
	// -- Get hashed version of supplied plaintext password. 
	var hashedPassword = utils.stringMD5HashBase64(password);
	var sql = 'select user_name,user_password,user_pn_account,user_uid from users where user_name=?';
	var dataset = databaseManager.getDataSetByQuery('mydatabase', sql, [userName], 1);
	
	// -- Should be one only!
	if (dataset.getMaxRowIndex() == 1)
	{
		// -- Test password. Value is in row 1 col 2 etc as per Select above.
		var storedPassword = dataset.getValue(1, 2);
		var user_uid = dataset.getValue(1, 4);
		var user_name = dataset.getValue(1, 1).toString();
		
		if (storedPassword == hashedPassword)
		{
                         // -- These both return false.
			//ret = security.login(user_name, user_uid, ['administrators']);
			ret = security.login(user_name, user_name, ['administrators']);
			
		}
	}
	
	return ret;
	
}

```

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [November 1, 2011, 6:11pm UTC](https://forum.servoy.com/t/why-does-security-login-always-return-false/14959/2 "2011-11-01T18:11:25Z")

</div>

and that authenticator solution you call from your client through the login solution?

are there any errors in your server log?

---

<div class="post-metadata">

**Author:** ![ptalbot](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/ptalbot/32/4952_2.png) [@ptalbot](https://forum.servoy.com/u/ptalbot)\
**Post date:** [November 1, 2011, 6:26pm UTC](https://forum.servoy.com/t/why-does-security-login-always-return-false/14959/3 "2011-11-01T18:26:47Z")

</div>

Also note that the groups are case-sensitive.  
Are you sure that it’s not ‘Administrators’ instead of ‘administrators’.

---

<div class="post-metadata">

**Author:** ![AlanBourke](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@AlanBourke](https://forum.servoy.com/u/AlanBourke)\
**Post date:** [November 2, 2011, 10:30am UTC](https://forum.servoy.com/t/why-does-security-login-always-return-false/14959/4 "2011-11-02T10:30:50Z")

</div>

> ptalbot:  
> Also note that the groups are case-sensitive.  
> Are you sure that it’s not ‘Administrators’ instead of ‘administrators’.

Patrick, if we ever meet please kick me in the pants for missing the obvious.

Thanks
