Guardian.anonymous? versus Guardian.is_anonymous?

Guardian has two verrrry similarly named predicates: anonymous? and is_anonymous?

What is the difference? :philosoraptor: :grimacing: :zipper_mouth_face:

4 Mi Piace

I agree, this can be confusing. :face_with_spiral_eyes:

anonymous? means that the user hasn’t logged in, so it’s an anonymous user browsing the site.

There’s an old feature that allows users to switch to an ā€œanonymousā€ user account. Using anonymous mode to reply or create topics
is_anonymous? means that the user has switched into that mode.

5 Mi Piace

Ah-ha…

Perhaps it would be better to rename is_anonymous? to is_user_in_anonymous_mode? ?

I guarantee there is at least one permissions-related bug already hiding in the codebase because someone mistakenly used the wrong method…

1 Mi Piace