Jump to content

Prevent multiple logins


Joe
 Share

Recommended Posts

Is it possible to block another user from logging in when someone else is logged in already?

The reason I am asking this: I'm setting up a test site for prospective clients. I have arranged it so the site gets set back to the original state every time someone logs in (DB gets restored from a backup copy). If someone else tries to log in at the same time though, things get messed up and have to reset things manually.

So I would like to make it impossible to log in if someone else is logged in already and show a message to that effect. My problem is I haven't figured out how to detect if another user is logged in before logging in. (I am using the PageEditSoftLock module, but for this it is not the right thing, even with the hard lock turned on. I need to keep other users from logging in, not just from editing pages.)

Link to comment
Share on other sites

Hi Martijn, that looks interesting and I may try to use it in another context: To allow people to test anonymously with a "test" user name and password. They could test a little, but without being able to save. I suppose that should be secure enough.

  • Like 1
Link to comment
Share on other sites

Hi Joe,

See here: https://processwire.com/talk/topic/4553-how-do-i-get-a-list-of-online-users/

It should be possible to get a list of online users.

You then need a Hook for example on this method: https://github.com/ryancramerdesign/ProcessWire/blob/dev/wire/core/Session.php#L311

Return false if there is already a user logged in.

Link to comment
Share on other sites

If we add a link in the pointed thread to this one, we'll get recursion :)

As long as it's not an infinite loop..... :-)

Yeah, right.  :lol:  I was aware of that post, but when I had tried I could not get the list to work. I will check it out again though and also look at Wanze's link. Thanks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...