mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 04:01:18 +08:00
FIX: guardian always got user but sometimes it is anonymous (#9342)
* FIX: guardian always got user but sometimes it is anonymous ``` def initialize(user = nil, request = nil) @user = user.presence || AnonymousUser.new @request = request end ``` AnonymouseUser defines `blank?` method ``` class AnonymousUser def blank? true end ... end ``` so if we would use @user.present? it would be correct, however, just @user is always true
This commit is contained in:

committed by
GitHub

parent
f8ec5f309a
commit
ce00da3bcd
@ -319,7 +319,7 @@ class Guardian
|
||||
# Support sites that have to approve users
|
||||
def can_access_forum?
|
||||
return true unless SiteSetting.must_approve_users?
|
||||
return false unless @user
|
||||
return false if anonymous?
|
||||
|
||||
# Staff can't lock themselves out of a site
|
||||
return true if is_staff?
|
||||
@ -442,7 +442,7 @@ class Guardian
|
||||
end
|
||||
|
||||
def can_export_entity?(entity)
|
||||
return false unless @user
|
||||
return false if anonymous?
|
||||
return true if is_admin?
|
||||
return entity != 'user_list' if is_moderator?
|
||||
|
||||
|
Reference in New Issue
Block a user