Skip to content

Commit

Permalink
Update error handling when inviting user to organization
Browse files Browse the repository at this point in the history
  • Loading branch information
adamaziz15 committed Dec 4, 2017
1 parent 066b889 commit 923493c
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,19 @@ def invite_member
user = MnoEnterprise::User.find_by(email: user_params[:email]) || create_unconfirmed_user(user_params)

# Create the invitation
invite = @organization.org_invites.create(
invite = MnoEnterprise::OrgInvite.create(
user_email: user.email,
user_role: params[:user][:role],
referrer_id: current_user.id,
status: 'staged' # Will be updated to 'accepted' for unconfirmed users
status: 'staged', # Will be updated to 'accepted' for unconfirmed users
organization_id: @organization.id
)

@user = user.confirmed? ? invite : user.reload
if invite.save
@user = user.confirmed? ? invite : user.reload
else
render json: invite.errors, status: :bad_request
end
end

protected
Expand Down

0 comments on commit 923493c

Please sign in to comment.