Download & Extend

user_authenticate returns empty user object after hook_auth

Project:Drupal core
Version:5.x-dev
Component:user.module
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (works as designed)

Issue Summary

When a module implements hook_auth to authenticate an existing user, the user_authentication function returns an user object with the wrong values iow it doesn't load the right user.

On line 1009 the user is loaded into $user_register, which calls user_save() when a user doesn't exist yet. This way, the $user object will get filled. However, if the user already exists (thus, it has an uid) the user object remains filled with the 'anonymous' user values, because the lack of an else statement.

This issue exists after commit #100096 by drumm at February 10, 2008 04:28 (Rev. 1.745.2.27)
The patch provided will fix this issue in 5.x-dev.

AttachmentSizeStatusTest resultOperations
20080814-user-authenticate.patch669 bytesIgnored: Check issue status.NoneNone

Comments

#1

Status:needs review» reviewed & tested by the community

Marking #287503: Passwords module not authenticating users as a duplicate of this.

I've also tested this patch and it works fine. Am marking reviewed and tested, as it's only a three line change and looks good, string me up if I'm wrong. ;-)

#2

Status:reviewed & tested by the community» closed (works as designed)

The behavior is by design: existing users can only be authenticated if they are in the authentication map.

Please see #283026: user_authenticate from external source (for existing users) not working with no server part.

nobody click here