Login error

Hi all,
I´m working on a new solution and trying to make a login on 5.2.2.
So i have a form in the login solution that calls a global method```
security.authenticate(“Authenticator”,globals.login(varCuit,varClaveFiscal), argumentsArray);

The error that appears is: Cannot find function login

My question is, whats the problem if the method is recognized when im writing the code

First, the “security.authenticate()” method is using a String as second argument, which is the name of a method in the Authenticator module of you solution, (and there’s no need to prefix this method name with “globals.” since your Authenticator module should really have nothing but globals anyway!).

So your method should read:

security.authenticate("Authenticator","login", [varCuit,varClaveFiscal]);

Then, you don’t call this from the Authenticator module itself, but from your Login module (usually from the login form of your Login module).

This is how the security is really ‘enhanced’:
Because you cannot access your Authenticator module differently than using the security.authenticate() method.

Also note that authenticate() returns an Object (meaning that it can be anything, and or example it can be a JSObject where you can put lots of information to be retrieved by the Login module - think of creating a User object, that will contain all relevant informations, like user ID, groups, name, etc.)
And finally, note that you can put many globals in your Authenticator module that will all be called the same way.

Hope this helps,

yea works tks
But I want to check userName and password and i have a data base where userName and password are located in a table. How can i check that password from the database table?

nromeou,

When your user is not logged in yet, he/she will have only access to the login solution and no database access.
But when you call a method in the authenticator (using security.authenticate()), the authenticator code is executed in the server in the authenticator solution and this solution has full access to the database.

So in the global ‘login’ method you can use foundsets, sql, etc to validate the username/password.
If valid, you should call security.login() in the authenticator, this will be picked up by the server and will trigger the client solution to load the main solution.

Rob

I have 2 diferent login methods. 1 normal to start the program and another for users who wants to register and the next error is shown…
Borrow prepareStatement from pool failed
like if one login method was calling the other

tks for the help

nromeou,

We will need some more info, like a stack trace from the logs or the smart client java console.

Rob

the console does not help me too much, the only message shown is:
Borrow prepareStatement from pool failed at loginA
but this is the code:

function loginA(userName, password) {
    
    if (userName == '123' && password == '123456')
        return security.login(userName, security.getUserUID(userName), ['Administrators'])
    var queryUN = 'select id, clave from tabla1 where userName = ? and password = ?'
    var args = new Array()
    args[0] = userName
    args[1] = password
    var dataset = databaseManager.getDataSetByQuery('server',queryUN,args,1)
    if(dataset.getMaxRowIndex()==1)
    {
        globals.globalUsername = userName 
        return security.login(userName, security.getUserUID(userName), ['Administrators'])
    }
    
    return false;
}

the error point me the line of:

var dataset = databaseManager.getDataSetByQuery('munibrown',queryUN,args,1)

tks for the help, really appreciate

nromeou,

Check the server log, it will contain a stack trace.

This is running in the authenticator solution, I assume?
If so, setting of the global does not do anything, the authenticating client in the server will be destroyed immediately after this call.

Rob

Btw, it is better practice to store passwords encrypted in your db and not in plain text.