switching users

Am I missing something or do you really have to quit developer when trying to switch users?

I’m implementing a security system and when trying to verify the different users, I always have to quit.

Just closing the solution and opening it again, does not present the login dialog box ?

Any insights appreciated

Hi Odysseus,

Yes, you do have to quit out of Servoy to “change” users. Why? Because Servoy will cache the last login info and (trying to be helpful) will try it when a solution requires login (to save you from having to type the same stuff over and over again).

Bob Cusick

As far as I followed the discussion, a “logout”-feature is on the wish list. You might not need to wait long for that :wink:

in the 2.1 beta you can logout. (see file menu)

And you can do this by method too?

currently not.
And it will also be a bit tricky because when you do logoff and the solution you are looking at needs a login, The solution will be closed.

so i can make a application.logOff() method but that one can also be closing the solution.

I have been doing this for a while:

(1) show a login page with two global fields for user name and user password.

(2) set your security up as you would normally but don’t require security to open the solution. then take the user to your custom login page on start up.

(3) run this code after the user fills out the two fields:

var ID = security.getUserId(globals.g_user);

var check = security.checkPassword(ID, globals.g_password);

if (check)
{
	forms.main_client_list.controller.show();
}
else
{
	plugins.dialogs.showErrorDialog('Error', 'Login incorrect','OK');
}

(4) to “logout”, simply send the user to the login page and clear the two globals. of course you will need to set all forms to non visible so that filling in this login page is the only way into your solution.

forms.splash.controller.show();

globals.g_user = '';
globals.g_password = '';
  • David

so i can make a application.logOff() method but that one can also be closing the solution.

Yes, what I want is that users are able to re-login, (with another username and password) without quitting the Servoy Client itself.

(that the solution must be closed first , is not a problem!)

A logout menu item is found in Servoy 2.1 beta2

Jan Blok:
A logout menu item is found in Servoy 2.1 beta2

Yes I found that one, but is Johan making this too: application.logOff() ?

So that you can do this by method?

will check if i can implement this method very easy.

made an method on application (2.1beta3)

I guess you knew that that was coming::slight_smile: Is there a way to retrieve the idle time of the solution for the current user?

what is idle?
And when do you get this info? Because at the moment you get this info (in a method) the user is doing something. Or you have to test this with the scheduler plugin..

That is what I thought about: checking for example every five minutes if the solution has been idle for the last 30 minutes. But probably checking something makes the solution “un-idle”?

david:
I have been doing this for a while:

(1) show a login page with two global fields for user name and user password.

(2) set your security up as you would normally but don’t require security to open the solution. then take the user to your custom login page on start up.

(3) run this code after the user fills out the two fields:

var ID = security.getUserId(globals.g_user);

var check = security.checkPassword(ID, globals.g_password);

if (check)
{
forms.main_client_list.controller.show();
}
else
{
plugins.dialogs.showErrorDialog(‘Error’, ‘Login incorrect’,‘OK’);
}

When I use this method, an error message appears:

“Can’t find method com.servoy.j2db.scripting.JSSecurity.js_checkPassword(null,string).”

What can this be?

That is because youre ID doesn’t contain a valid id (and int like 1,2 or 3)

I made the security node a bit better so it can handle null values a bit better.

Thanks! But because I’m a very newbie, what do I need to do? I tried to create a new column with the name ‘ID’, but that didn’t solve it… :(

youre globals.g_user is not filled..

you have to fill with globals.g_user = security.getUser() (or something like that) But then the users have to login (solution requires a login see security dialog) so that there is a user.

Trying to help FreeColours with his problem, I notices that the sample code for security.getUserId( [username]) doen’t show how to use the security.getUserId( [username]) function…

Same goes for security.getUserName( [user_id])

As for your issue FreeColour: I think that what jcompager means is that is seems that var ID holds no value and therefor security.checkPassword(ID, globals.g_password); gives an error.

You do not check if the username the user filled in actually exists. If it doesn’t exists, the ID will be empty.

Paul