Hi,

very interesting projet, I can immediately see the use of this.

Just to clarify: Do I understand the code correctly, that users who are logged in when I disable the login, are not going to be logged out?

Comments

berliner’s picture

Ok, I tested this, and logged in users stay logged in until they log out.

I would suggest two things:
1. Add an option to log out users once the login is disabled
2. Integrate the module options into the maintenance settings. Semantically it is there that maintenance is handled.

You could even add your modules functionality to the maintenance options (online / offline / logout users and prevent login). That way site admins can choose depending on the maintenance tasks that are going to be executed. E.g. for pure content related modifications to a site where the code and database structure is not affected, a login prevention is sufficient, where as other tasks would require a deeper maintenance status, so that php or database errors won't be displayed.

budda’s picture

I was considering truncating the sessions table to log out everyone - or maybe everyone except user id 1?

Thanks for the suggestion on the maintenance page. Good idea!

lhugg’s picture

Has a decision been made on whether an option will be added to log out currently logged-in users? This is a great module, but I was surprised to find it wasn't really doing what I THOUGHT it was doing when I noticed users logging into the site where that I thought was disabled. Drupal typically maintains sessions for weeks unless a user logs out, so truncating the session table might be a great option.

What is the status of this request?

Letharion’s picture

Category: support » feature
gisle’s picture

Category: feature » support

I think this is an undesireable feature, so I am reverting the state to "support request" (and suggest that it is closed as "closed (won't fix)" - but I'll leave that call to the maintainer.

As for logging out all logged in users, just set your site to maintenance mode (this will automatically gracefully log out all logged-in users except the admin). Then enable Login Disable and revert from maintenance mode.

My use case for Login Disable requires logged in users to stay logged in - I just don't want any new user to be able to log in. So I see no need for this feature. And if you need it, just popping in and out of maintenance mode will do it.

berliner’s picture

Category: support » feature

Setting back to feature request as that is what it actually is.

@Budda: If you need a hand, just say so.

damienmckenna’s picture

Version: 6.x-1.0 » 7.x-1.x-dev
Issue summary: View changes

Probably the best solution would be a Form API submission callback on the settings page, so that when the functionality is enabled it deletes sessions except for the current user.

budda’s picture

@berliner open to a patch submission for this as i've not got time to work on new features at present but happy to review / tests - as others here maybe too.

gisle’s picture

If you implement this "feature", make sure there is an option to disable it.

I am currently using this module to disable new logins but letting logged in users finish their business in a graceful manner (before moving on to maintenance mode). If this "feature" is implemented without a way to disable it, my use case will break.

damienmckenna’s picture

@gisle: I think the idea would be for it to be a one-time thing - any user who was not supposed to be logged in anymore (based on permission) would be logged out.

Leeteq’s picture

@DamienMcKenna: what does "not supposed" mean in this case? How to reliably identify them and make sure others are not logged out?

I agree with @gisle in that this should at least be made optional in the admin interface, so that both use cases are covered.

abarpetia’s picture

Hello,
This is old request but I think it will be worth to have this feature. I agree with @gisle regarding option to disable this feature. Here is the patch which is adding option field into module's configuration page and based on this field value it deleting sessions of all logged in users except current user and User 1.

Please take a look at this patch.

mortona2k’s picture

Status: Active » Reviewed & tested by the community

Great patch! I verified that it worked, and I would accept it as is, with some recommendations for future work. I see this module being useful for D8.

It would be good only logout users without permission. If this was used in some scenarios, it may have disruptive effects for sensitive users.

Post the configured message after they're logged out, so they know what's going on.

alfaguru’s picture

I don't think truncating the session table is the right way to go for two reasons.

  1. There's no need to discard sessions that aren't actively in use at the time. This may include shopping carts, for example.
  2. It doesn't deal with cases such as SSO logins, where sessions can be created dynamically by other means.

So I would suggest the following alternative logic (pseudo-code), in a hook_init.

IF user is logged in AND the flag to logout users is on AND user is not an admin THEN
  log user out
  redirect to page with message
ENDIF
baikho’s picture

Status: Reviewed & tested by the community » Needs work

There's a small typo in the patch:

When active all the logged in users will be forced to loggout.

should be "When active all the logged in users will be forced to logout." (omit 1 g from "loggout")