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
|
end
|
||||||
|
|
||||||
# generate invite link
|
# generate invite link
|
||||||
invite_link = Invite.generate_invite_link(params[:email], current_user, topic, group_ids)
|
if invite_link = Invite.generate_invite_link(params[:email], current_user, topic, group_ids)
|
||||||
render_json_dump(invite_link)
|
render_json_dump(invite_link)
|
||||||
|
else
|
||||||
|
render json: failed_json, status: 422
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_disposable_invite
|
def create_disposable_invite
|
||||||
|
|
|
@ -79,7 +79,7 @@ class Invite < ActiveRecord::Base
|
||||||
# generate invite link
|
# generate invite link
|
||||||
def self.generate_invite_link(email, invited_by, topic=nil, group_ids=nil)
|
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)
|
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
|
end
|
||||||
|
|
||||||
# Create an invite for a user, supplying an optional topic
|
# Create an invite for a user, supplying an optional topic
|
||||||
|
|
Loading…
Reference in New Issue