Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Since this is an authentication module it's really unnecessary for it to do a lot of thinking upon each page load, even when the user is already logged in. Wrapping most of webserver_auth_init() in if (!$user->uid) is my fix:
function webserver_auth_init() {
global $user, $domain, $account;
if (!$user->uid) {
[SNIP]
}
}
The reason why I need this very much is because I've made another module which is called upon hook_user('load') and would be called upon each and every page load, due to user_external_load($name) calling it.
Comments
Comment #1
moshe weitzman CreditAttribution: moshe weitzman commentedthat makes sense but there was some reason i did it that way. i think in some cases you want to login as another user and we won't be able to change users if we never execute this code. note end of this comment:
//do nothing because user is already logged into Drupal, and hasn't presented different credentials vis web server
Comment #2
ronnqvist CreditAttribution: ronnqvist commentedOK... problem solved, wrap the code in this instead.
if ($user->name != $_SERVER["REMOTE_USER"]) {
(Of course you might want to do the trimming stuff to $_SERVER["REMOTE_USER"] first, but this worked for me.)
Comment #3
geste CreditAttribution: geste commentedWith respect to Moshe's point #1....
In my circumstance, I never want to allow anybody to log in to Drupal as any ID other than what they are showing in REMOTE_USER. Although it was tricky at first to get my REMOTE_USER account promoted to admin.
After it was all set I simply removed login block. There's probably a gotcha here somewhere :)
Comment #4
ronnqvist CreditAttribution: ronnqvist commentedgeste, I think you might have misunderstood Moshe here a little bit. I think he was talking about that if one wanted to log in as a different user, Drupal wouldn't recognise that change of user. My later patch fixes that however.
Comment #5
gaards CreditAttribution: gaards commentedClosed because Drupal 4.7 is not supported. If the issue verifiably applies to later versions, please reopen with details and update the version.