FIX: Allow add email to group if user can invite (#13097)

It used to allow adding email addresses to a group even if invites were
disabled for the site. This does not allow user to input email address
if they cannot invite.

The second thing this commit improves is the message that is displayed
to the user when they hit the invite rate limit.
This commit is contained in:
Bianca Nenciu
2021-05-21 11:34:17 +03:00
committed by GitHub
parent 4ce854f21c
commit 38af28d58b
5 changed files with 29 additions and 8 deletions

View File

@ -368,7 +368,15 @@ class GroupsController < ApplicationController
end
emails.each do |email|
Invite.generate(current_user, email: email, group_ids: [group.id])
begin
Invite.generate(current_user, email: email, group_ids: [group.id])
rescue RateLimiter::LimitExceeded => e
return render_json_error(I18n.t(
"invite.rate_limit",
count: SiteSetting.max_invites_per_day,
time_left: e.time_left
))
end
end
render json: success_json.merge!(