# Having some issues creating a login solution

**URL:** https://forum.servoy.com/t/having-some-issues-creating-a-login-solution/15986
**Category:** Classic Servoy
**Created:** [June 1, 2012, 4:38pm UTC](https://forum.servoy.com/t/having-some-issues-creating-a-login-solution/15986 "2012-06-01T16:38:16Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![volcodc](https://avatars.discourse-cdn.com/v4/letter/v/ea5d25/32.png) [@volcodc](https://forum.servoy.com/u/volcodc)
#### Post date: [June 1, 2012, 4:38pm UTC](https://forum.servoy.com/t/having-some-issues-creating-a-login-solution/15986/1 "2012-06-01T16:38:16Z")

</div>

Hello again,

First of all, sorry in advance for my multiple posts with beginner questions, still trying to get the hang of the feature-filled API of Servoy.

I first created an unsecure login form that just checked the Username and Password in the DB, and then proceeded.  
After looking around though, it seems I should be using the security functions that come with Servoy.

I have written some code to try and perform this task:

function loginToForm(event){  
var userUID = security.getUserUID(userNameField);  
var userGroups = security.getUserGroups(userUID);  
var checkPW = security.checkPassword(userUID,passWordField);

if(checkPW){  
security.login(userNameField,userUID,userGroups);  
application.output(‘logged in’);  
}  
else {  
application.output(‘failed login’);  
}  
}

userNameField and passWordField are tied to text areas on the form where the user inputs their information.

I am getting an error on the security.login line, saying I cannot provide String,String,JSDataSet, and instead to provide String,Object,Array.  
As you can tell I am using the supported methods that come with the Security property. Why won’t the provided methods fit together? Shouldn’t security.getUserUID return the UID in a manner that would fit the security.login method?

Thanks in advance for any assistance!  
Chris

---

<div class="post-metadata">

### Author: ![mboegem](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/mboegem/32/4399_2.png) [@mboegem](https://forum.servoy.com/u/mboegem)
#### Post date: [June 1, 2012, 10:10pm UTC](https://forum.servoy.com/t/having-some-issues-creating-a-login-solution/15986/2 "2012-06-01T22:10:38Z")

</div>

Hi Chris,

actually the ‘getUserGroups’ function is returning a dataset.  
from that dataset you need to get the correct column (thought this is column 2) as an array:

```auto
/** @type {Array<String>} */
var groupArray = userGroups.getColumnAsArray(2);

```

Then use the groupArray to pass to the login function.

Hope this helps

---

<div class="post-metadata">

### Author: ![volcodc](https://avatars.discourse-cdn.com/v4/letter/v/ea5d25/32.png) [@volcodc](https://forum.servoy.com/u/volcodc)
#### Post date: [June 4, 2012, 3:58pm UTC](https://forum.servoy.com/t/having-some-issues-creating-a-login-solution/15986/3 "2012-06-04T15:58:29Z")

</div>

> mboegem:  
> Hi Chris,
> 
> actually the ‘getUserGroups’ function is returning a dataset.  
> from that dataset you need to get the correct column (thought this is column 2) as an array:
> 
> ```auto
> /** @type {Array<String>} */
> 
> ```

var groupArray = userGroups.getColumnAsArray(2);

> ```auto
> 
> Then use the groupArray to pass to the login function.
> 
> Hope this helps
> 
> ```

Thanks for the assistance!  
I had already tried the getColumnAsArray(2), tho what fixed it is adding the /\*\* @type {Array} \*/  
I was under the impression that doc comments weren’t programatically relevant, but it seems I am wrong.

---

<div class="post-metadata">

### Author: ![volcodc](https://avatars.discourse-cdn.com/v4/letter/v/ea5d25/32.png) [@volcodc](https://forum.servoy.com/u/volcodc)
#### Post date: [June 5, 2012, 2:44pm UTC](https://forum.servoy.com/t/having-some-issues-creating-a-login-solution/15986/4 "2012-06-05T14:44:53Z")

</div>

**EDIT: I noticed when I launch the smart client it’s automatically logging me in to some “dummy-login”. How am I supposed to test out my own login solution if the system keeps auto logging me in dummy-login?**

_Why would the security.login() return false?_  
_I have traced each value I am passing into the function, which has the correct username, UUID, and groups, but it just returns false no matter what._  
_What could be causing this?_  
_Thanks,_  
_Chris_
