Skip to content

Commit

Permalink
handle invite not found
Browse files Browse the repository at this point in the history
  • Loading branch information
nid90 committed Jan 6, 2025
1 parent b95a1d5 commit f418ba9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/controllers/accounts/invitations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ def create
end

def destroy
@invite = Accounts::Organization.find_by!(slug: params[:organization_id])
.pending_invites.find(params[:id])
@invite.destroy
redirect_to accounts_organization_teams_path(current_organization),
notice: "Invitation to #{@invite.email} has been cancelled"
@invite = current_organization.pending_invites.find_by(id: params[:id])

if @invite&.destroy
redirect_to accounts_organization_teams_path(current_organization),
notice: "Invitation to #{@invite.email} has been cancelled"
else
redirect_to accounts_organization_teams_path(current_organization),
flash: {error: "Could not cancel the invitation."}
end
end

protected
Expand Down

0 comments on commit f418ba9

Please sign in to comment.