Skip to content

Commit

Permalink
Fix sender email for invited users to be of the correct org
Browse files Browse the repository at this point in the history
  • Loading branch information
nid90 committed Mar 13, 2024
1 parent 0063b19 commit 4f781df
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/controllers/accounts/organizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def teams
[2, "Team", teams_accounts_organization_path(current_organization), "v2/user_cog.svg"]
]
@teams = current_organization.teams
@users = current_organization.users.includes(:invitations)
@invited_users = current_organization.invites.includes(:sender).not_accepted
@users = current_organization.members
@invited_users = current_organization.pending_invites
end

def rotate_api_key
Expand Down
8 changes: 8 additions & 0 deletions app/models/accounts/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ def default_app
apps.first
end

def members
users.includes(memberships: :organization, invitations: :organization)
end

def pending_invites
invites.includes(:sender).not_accepted
end

def team_colors
colors = teams.pluck(:name, :color).to_h || {}
colors[Accounts::Team::UNKNOWN_TEAM_NAME] = Accounts::Team::UNKNOWN_TEAM_COLOR
Expand Down
6 changes: 4 additions & 2 deletions app/models/accounts/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@ def owner_for?(organization)
access_for(organization).owner?
end

def successful_invite
invitations.find(&:accepted?)
def successful_invite_for(organization)
invitations
.filter { |i| i.organization == organization }
.find(&:accepted?)
end

def release_monitoring?
Expand Down
2 changes: 1 addition & 1 deletion app/views/accounts/organizations/_teams.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<%= render V2::TeamPillComponent.new(member.team_for(current_organization)) %>
<% end %>
<% row.with_cell do %>
<%= member.successful_invite&.sender&.email || "–" %>
<%= member.successful_invite_for(current_organization)&.sender&.email || "–" %>
<% end %>
<% end %>
<% end %>
Expand Down

0 comments on commit 4f781df

Please sign in to comment.