mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-06-30 11:32:18 +00:00
FIX: Invalid access error should be populated to user (#1303)
Invalid access error should be populated to user when trying to search for something they do not have permissions for (i.e. anons searching `in:messages`
This commit is contained in:
parent
1e32416eaa
commit
ab67299acb
@ -46,11 +46,19 @@ module DiscourseAi
|
|||||||
end
|
end
|
||||||
|
|
||||||
hijack do
|
hijack do
|
||||||
|
begin
|
||||||
semantic_search
|
semantic_search
|
||||||
.search_for_topics(query, _page = 1, hyde: !skip_hyde)
|
.search_for_topics(query, _page = 1, hyde: !skip_hyde)
|
||||||
.each { |topic_post| grouped_results.add(topic_post) }
|
.each { |topic_post| grouped_results.add(topic_post) }
|
||||||
|
|
||||||
render_serialized(grouped_results, GroupedSearchResultSerializer, result: grouped_results)
|
render_serialized(
|
||||||
|
grouped_results,
|
||||||
|
GroupedSearchResultSerializer,
|
||||||
|
result: grouped_results,
|
||||||
|
)
|
||||||
|
rescue Discourse::InvalidAccess
|
||||||
|
render_json_error(I18n.t("invalid_access"), status: 403)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import { SEARCH_TYPE_DEFAULT } from "discourse/controllers/full-page-search";
|
|||||||
import concatClass from "discourse/helpers/concat-class";
|
import concatClass from "discourse/helpers/concat-class";
|
||||||
import icon from "discourse/helpers/d-icon";
|
import icon from "discourse/helpers/d-icon";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||||
import { isValidSearchTerm, translateResults } from "discourse/lib/search";
|
import { isValidSearchTerm, translateResults } from "discourse/lib/search";
|
||||||
import { i18n } from "discourse-i18n";
|
import { i18n } from "discourse-i18n";
|
||||||
import DTooltip from "float-kit/components/d-tooltip";
|
import DTooltip from "float-kit/components/d-tooltip";
|
||||||
@ -193,6 +194,7 @@ export default class AiFullPageSearch extends Component {
|
|||||||
|
|
||||||
this.AiResults = model.posts;
|
this.AiResults = model.posts;
|
||||||
})
|
})
|
||||||
|
.catch(popupAjaxError)
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
this.searching = false;
|
this.searching = false;
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user