Only search users via rest API if user has permission (#73)

Closes https://github.com/flarum/core/issues/3070

If the user doesn't have permission to search users, there will currently be browser errors, as the current implementation will still attempt to search and autocomplete. In this PR, we check for permission before searching. The dropdown will still support autocomplete of users currently participating in the discussion.
This commit is contained in:
Alexander Skvortsov 2021-10-13 14:57:45 -04:00 committed by GitHub
parent ac427a8a4a
commit a2832af01f

View File

@ -224,7 +224,7 @@ export default function addComposerAutocomplete() {
// Don't send API calls searching for users until at least 2 characters have been typed.
// This focuses the mention results on users and posts in the discussion.
if (typed.length > 1) {
if (typed.length > 1 && app.forum.attribute('canSearchUsers')) {
throttledSearch(typed, searched, returnedUsers, returnedUserIds, dropdown, buildSuggestions);
}
}