Project

General

Profile

How to limit access to a single user/session?

Added by Ford Burton over 11 years ago

Is there a way to limit access to a Wt program to a single user/session? I'm designing an embedded application with device control and data acquisition and it would be bad if there were multiple users trying to access the hardware. I'm thinking perhaps the authentication module but can you prevent a second login to a given user name if the system already has that user logged in?


Replies (2)

RE: How to limit access to a single user/session? - Added by Fahmi Noorain over 11 years ago

I think it is possible to using WApplication::sessionId(). Get the sessionId from first user and then deny another.

RE: How to limit access to a single user/session? - Added by Wim Dumon over 11 years ago

You could create a class that inherits from WApplication, sets a global flag in the constructor, and resets it in the destructor. Before setting the flag you test if it is already set; if it is, display a message to the user and call WApplication::quit() (but don't reset the flag in the WApplication destructor in this case...).

If you want to do this per user, use the same principle: when a user logs in, set a flag next to his name; when the application object is destroyed, remove the flag.

BR,

Wim.

    (1-2/2)