Masquerade and IP Login

Last updated on
30 April 2025

I use Masquerade with the IP Login module to let users use their own login under an IP login. If there is enough interest, I will document the connection here. There is an issue with more details at #1300806: Let users login to their own account without logging out.

For more details, see the following issues:
#1300806: Let users login to their own account without logging out
#1416136: Would like to switch based on role and alter user login
#1425380: masquerade_user_logout($account) $_SESSION['masquerading']

The IP Login module logs people in by IP address, a common situation in libraries and big institutions. The Masquerade module then lets a person log in under their own login. There are several modifications to Masquerade that should be in a separate module and I will look at splitting out the code for easier maintenance.

Masquerade over IP

I started splitting my IP login code out to module Masquerade over IP.

masquerade_init()

Masquerade puts the user id in a session variable if found in the {masquerade} table. This indicates the user is masquerading. I added a hook to let my module add and modify roles.
module_invoke_all('masquerade_init_modify_user', $user);

masquerade__over_ip_menu()

The user logs in through user/login. I replicate the login as user/ip/login so I can add extra code to handle the complicated user configuration.

Help improve this page

Page status: Not set

You can: