DEV: Revert guardian changes (#24742)

I took the wrong approach here, need to rethink.

* Revert "FIX: Use Guardian.basic_user instead of new (anon) (#24705)"

This reverts commit 9057272ee2.

* Revert "DEV: Remove unnecessary method_missing from GuardianUser (#24735)"

This reverts commit a5d4bf6dd2.

* Revert "DEV: Improve Guardian devex (#24706)"

This reverts commit 77b6a038ba.

* Revert "FIX: Introduce Guardian::BasicUser for oneboxing checks (#24681)"

This reverts commit de983796e1.
This commit is contained in:
Martin Brennan
2023-12-06 16:37:32 +10:00
committed by GitHub
parent ac60b9fe72
commit 30d5e752d7
14 changed files with 25 additions and 221 deletions

View File

@@ -22,7 +22,7 @@ class AboutController < ApplicationController
end
category_topic_ids = Category.select(:topic_id).where.not(topic_id: nil)
public_topics =
Topic.listable_topics.visible.secured(Guardian.anon_user).where.not(id: category_topic_ids)
Topic.listable_topics.visible.secured(Guardian.new(nil)).where.not(id: category_topic_ids)
stats = { public_topic_count: public_topics.count }
stats[:public_post_count] = public_topics.sum(:posts_count) - stats[:public_topic_count]
render json: stats

View File

@@ -47,6 +47,6 @@ class EmailController < ApplicationController
user = User.find_by_email(@email)
raise Discourse::NotFound unless user
topic = Topic.find_by(id: params[:topic_id].to_i) if @topic_id
@topic = topic if topic && Guardian.anon_user.can_see?(topic)
@topic = topic if topic && Guardian.new(nil).can_see?(topic)
end
end