mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 00:01:13 +08:00
FIX: Error message for 403 when featuring topic on profile (#9149)
This commit is contained in:

committed by
GitHub

parent
5037b80c9c
commit
3ad5cb0cbc
@ -1362,7 +1362,10 @@ class UsersController < ApplicationController
|
|||||||
user = fetch_user_from_params
|
user = fetch_user_from_params
|
||||||
topic = Topic.find(params[:topic_id].to_i)
|
topic = Topic.find(params[:topic_id].to_i)
|
||||||
|
|
||||||
raise Discourse::InvalidAccess.new unless topic && guardian.can_feature_topic?(user, topic)
|
if !guardian.can_feature_topic?(user, topic)
|
||||||
|
return render_json_error(I18n.t('activerecord.errors.models.user_profile.attributes.featured_topic_id.invalid'), 403)
|
||||||
|
end
|
||||||
|
|
||||||
user.user_profile.update(featured_topic_id: topic.id)
|
user.user_profile.update(featured_topic_id: topic.id)
|
||||||
render json: success_json
|
render json: success_json
|
||||||
end
|
end
|
||||||
|
@ -546,6 +546,10 @@ en:
|
|||||||
same_as_password: "is the same as your password."
|
same_as_password: "is the same as your password."
|
||||||
ip_address:
|
ip_address:
|
||||||
signup_not_allowed: "Signup is not allowed from this account."
|
signup_not_allowed: "Signup is not allowed from this account."
|
||||||
|
user_profile:
|
||||||
|
attributes:
|
||||||
|
featured_topic_id:
|
||||||
|
invalid: "This topic cannot be featured on your profile."
|
||||||
user_email:
|
user_email:
|
||||||
attributes:
|
attributes:
|
||||||
user_id:
|
user_id:
|
||||||
|
@ -129,6 +129,7 @@ module UserGuardian
|
|||||||
end
|
end
|
||||||
|
|
||||||
def can_feature_topic?(user, topic)
|
def can_feature_topic?(user, topic)
|
||||||
|
return false if topic.nil?
|
||||||
return false if !SiteSetting.allow_featured_topic_on_user_profiles?
|
return false if !SiteSetting.allow_featured_topic_on_user_profiles?
|
||||||
return false if !is_me?(user) && !is_staff?
|
return false if !is_me?(user) && !is_staff?
|
||||||
return false if !topic.visible
|
return false if !topic.visible
|
||||||
|
Reference in New Issue
Block a user