FIX: return 422 if the invite is already redeemed
This commit is contained in:
parent
cc75890cd4
commit
f2c1dbaa68
|
@ -60,8 +60,11 @@ class InvitesController < ApplicationController
|
|||
end
|
||||
|
||||
# generate invite link
|
||||
invite_link = Invite.generate_invite_link(params[:email], current_user, topic, group_ids)
|
||||
render_json_dump(invite_link)
|
||||
if invite_link = Invite.generate_invite_link(params[:email], current_user, topic, group_ids)
|
||||
render_json_dump(invite_link)
|
||||
else
|
||||
render json: failed_json, status: 422
|
||||
end
|
||||
end
|
||||
|
||||
def create_disposable_invite
|
||||
|
|
|
@ -79,7 +79,7 @@ class Invite < ActiveRecord::Base
|
|||
# generate invite link
|
||||
def self.generate_invite_link(email, invited_by, topic=nil, group_ids=nil)
|
||||
invite = create_invite_by_email(email, invited_by, topic, group_ids, false)
|
||||
return "#{Discourse.base_url}/invites/#{invite.invite_key}"
|
||||
return "#{Discourse.base_url}/invites/#{invite.invite_key}" if invite
|
||||
end
|
||||
|
||||
# Create an invite for a user, supplying an optional topic
|
||||
|
|
Loading…
Reference in New Issue