I'm unable to log in to a site with email OR username login enabled when user entities are not visible to anonymous users.

This is because the Drupal\email_registration\UserAuthentication::lookupAccount method uses an entity query to do the user lookup, and this query has access checking enabled.

Let's disable that access check as this query needs to return a user before we have a logged in user.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

thtas created an issue. See original summary.

thtas’s picture

Title: Remove access check from UserAuth:lookupAccount query » Remove access check from UserAuthentication:lookupAccount query

thtas’s picture

Status: Active » Needs review
estebanvalerio.h’s picture

@thtas I'm not able to reproduce the issue with module version 2.x-dev.
After installing it, I was able to log in with username or email.
I check the code update at https://git.drupalcode.org/project/email_registration/-/merge_requests/5... and compare it with the code on my environment, the accessCheck is set to TRUE and this wasn't a blocker to log in
Can you specify which steps to follow to reproduce the issue? Thanks

thtas’s picture

The issue arises when some modules need to have a say on the query access for user entities.

e.g. in my scenario, I have a site which uses the groups module which will implement query level access and is configured in such a way that users are not visible to anonymous users.

This could also happen if you used the "entity" module and implemented a query access handler for user entities.

Also, the parent call from the core class that this class extends from will also skip access checking as it uses the entity storage loadByProperties method.

jonathanshaw’s picture

Status: Needs review » Reviewed & tested by the community

Yes, this is the correct approach.

greggles’s picture

Status: Reviewed & tested by the community » Needs work

Needs work for that comment on the MR.

santanu mondal made their first commit to this issue’s fork.

santanu mondal’s picture

Status: Needs work » Needs review