Skip to content

Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.

Show each member's chosen email everywhere others see it

Guido Boyked2458ccb4fd7
diff --git a/.github/workflows/guards.yml b/.github/workflows/guards.yml
index 84658dc..527fc14 100644
--- a/.github/workflows/guards.yml
+++ b/.github/workflows/guards.yml
@@ -239,6 +239,7 @@ jobs:
spec/models/time_sessions/list_filters_spec.rb
spec/models/membership_spec.rb
spec/models/user/avatar_spec.rb
+ spec/models/user/email_display_spec.rb
spec/models/user/name_display_spec.rb
spec/models/user/preference_store_spec.rb
spec/models/user/preferences_form_spec.rb
@@ -331,6 +332,7 @@ jobs:
spec/requests/organisations/meetings_overview_create_spec.rb
spec/models/person_spec.rb
spec/requests/organisations/people_spec.rb
+ spec/requests/organisations/shown_email_spec.rb
spec/services/people/directory_spec.rb
spec/services/people/contacts_spec.rb
spec/services/people/lookup_spec.rb
diff --git a/app/components/neo_filter_bar_component.rb b/app/components/neo_filter_bar_component.rb
index b60a4b0..a01c5fc 100644
--- a/app/components/neo_filter_bar_component.rb
+++ b/app/components/neo_filter_bar_component.rb
@@ -573,7 +573,7 @@ class NeoFilterBarComponent < ViewComponent::Base
return '{}' if ids.empty?
organisation.users.where(id: ids)
- .each_with_object({}) { |u, map| map[u.id] = u.display_name.presence || u.email }
+ .each_with_object({}) { |u, map| map[u.id] = u.display_name }
.to_json
end
diff --git a/app/components/overview/activity_feed_component.html.erb b/app/components/overview/activity_feed_component.html.erb
index 56145b0..16a5dc5 100644
--- a/app/components/overview/activity_feed_component.html.erb
+++ b/app/components/overview/activity_feed_component.html.erb
@@ -30,7 +30,7 @@
<% end %>
</div>
<div class="font-mono text-xs text-cream-600 mt-0.5">
- <%= group.actor&.first_name || group.actor&.email&.split('@')&.first || t('dashboard.briefing.system') %>
+ <%= group.actor&.first_name.presence || group.actor&.display_name || t('dashboard.briefing.system') %>
· <%= helpers.time_ago_in_words(group.latest_at) %>
</div>
</div>
diff --git a/app/controllers/organisations/base_controller.rb b/app/controllers/organisations/base_controller.rb
index 24f1bb0..3d6e41d 100644
--- a/app/controllers/organisations/base_controller.rb
+++ b/app/controllers/organisations/base_controller.rb
@@ -92,7 +92,7 @@ class Organisations::BaseController < ApplicationController
violation = Subscriptions::GuestCeiling.new(account).violation_for(user)
return unless violation
- flash[:warning] = t('shared.guest_ceiling.exceeded_hint', user: user.full_name.presence || user.email)
+ flash[:warning] = t('shared.guest_ceiling.exceeded_hint', user: user.display_name)
rescue StandardError => e
# Best-effort by design: the triggering write has already committed when
# this runs, so a detection failure (broken sibling-org data in the same
diff --git a/app/controllers/organisations/memberships_controller.rb b/app/controllers/organisations/memberships_controller.rb
index 63db7d1..87b9220 100644
--- a/app/controllers/organisations/memberships_controller.rb
+++ b/app/controllers/organisations/memberships_controller.rb
@@ -117,12 +117,13 @@ class Organisations::MembershipsController < Organisations::BaseController
@invitations = policy_scope(Invitation).pending.order(sent_at: :desc)
@roles = policy_scope(Role).order(:title).to_a if current_user.account_admin_in?(current_organisation)
query = params[:q].to_s.strip.downcase
- @memberships.select! { |member| [member.user.full_name, member.user.email].any? { |value| value.to_s.downcase.include?(query) } } if query.present?
+ # The shown email only (User::EmailDisplay): a hidden login address is neither matched nor sorted by.
+ @memberships.select! { |member| [member.user.full_name, member.user.shown_email].any? { |value| value.to_s.downcase.include?(query) } } if query.present?
@memberships.sort_by! do |member|
case params[:sort]
when 'role' then [helpers.membership_role_name(member.role).downcase, member.user.full_name.to_s.downcase, member.id]
when 'since' then [member.created_at, member.id]
- else [helpers.viewer_display_name(member.user).downcase, member.user.email, member.id]
+ else [helpers.viewer_display_name(member.user).downcase, member.user.shown_email.to_s, member.id]
end
end
@memberships.reverse! if params[:direction] == 'desc'
diff --git a/app/controllers/organisations/notification_subscriptions_controller.rb b/app/controllers/organisations/notification_subscriptions_controller.rb
index b2cc82e..6e522c0 100644
--- a/app/controllers/organisations/notification_subscriptions_controller.rb
+++ b/app/controllers/organisations/notification_subscriptions_controller.rb
@@ -115,14 +115,14 @@ module Organisations
users = accessible.where.not(id: subscribed_user_ids)
if params[:q].present?
- query = "%#{params[:q].downcase}%"
- users = users.where(
- 'LOWER(first_name) LIKE :q OR LOWER(last_name) LIKE :q OR LOWER(email) LIKE :q',
- q: query
- )
+ query = "%#{User.sanitize_sql_like(params[:q].downcase)}%"
+ # Names, and the email each member shows to others (User::EmailDisplay):
+ # a hidden login address is never matched, so the picker cannot confirm it.
+ by_name = users.where('LOWER(first_name) LIKE :q OR LOWER(last_name) LIKE :q', q: query)
+ users = by_name.or(users.merge(User.matching_shown_email(params[:q])))
end
- render json: users.limit(20).map { |u| { id: u.id, name: u.full_name, email: u.email } }
+ render json: users.limit(20).map { |u| { id: u.id, name: u.full_name, email: u.shown_email } }
end
private
diff --git a/app/controllers/organisations/smart_folders_controller.rb b/app/controllers/organisations/smart_folders_controller.rb
index 7446c2f..ef40cc5 100644
--- a/app/controllers/organisations/smart_folders_controller.rb
+++ b/app/controllers/organisations/smart_folders_controller.rb
@@ -346,8 +346,9 @@ class Organisations::SmartFoldersController < Organisations::BaseController
def share
authorize @smart_folder
- @users_for_sharing = shareable_users.order(:email)
- @existing_shares = @smart_folder.smart_folder_shares.includes(:user).order('users.email')
+ # By name: the login address is no label here (User::EmailDisplay).
+ @users_for_sharing = shareable_users.order(:last_name, :first_name, :id)
+ @existing_shares = @smart_folder.smart_folder_shares.includes(:user).order('users.last_name', 'users.first_name', 'users.id')
respond_to do |format|
format.html
diff --git a/app/helpers/people_helper.rb b/app/helpers/people_helper.rb
index a8321a2..a45046d 100644
--- a/app/helpers/people_helper.rb
+++ b/app/helpers/people_helper.rb
@@ -183,14 +183,15 @@ module PeopleHelper
# The fixed fields of the lane, in the order of the form, without the
# company (person_kind_line).
def person_fixed_fields(person, member)
- email = member ? member.email : person&.email
+ email = member ? member.shown_email : person&.email
phone = person&.phone
[
({ label: Person.human_attribute_name(:salutation), value: person.salutation } if person&.salutation.present?),
({ label: Person.human_attribute_name(:function), value: person.function } if person&.function.present?),
({ label: Person.human_attribute_name(:department), value: person.department } if person&.department.present?),
- # A member's email is the account's, checked by Devise only: linked as
- # it is, not through PersonDetail's stricter rule.
+ # A member's email is the one they show to others (User#shown_email),
+ # checked by the account's own validation: linked as it is, not through
+ # PersonDetail's stricter rule.
({ label: Person.human_attribute_name(:email), value: email, href: "mailto:#{email}", icon: 'bi-envelope', reach: true } if email.present?),
if phone.present?
{ label: Person.human_attribute_name(:phone), value: phone, href: PersonDetail.new('kind' => 'phone', 'value' => phone).href,
diff --git a/app/javascript/controllers/subscriber_picker_controller.js b/app/javascript/controllers/subscriber_picker_controller.js
index 310c6ee..c17efdb 100644
--- a/app/javascript/controllers/subscriber_picker_controller.js
+++ b/app/javascript/controllers/subscriber_picker_controller.js
@@ -123,7 +123,7 @@ export default class extends Controller {
<i class="bi bi-person text-gray-400" style="font-size: 14px;"></i>
<div>
<div class="font-medium text-gray-800">${this._escapeHtml(user.name)}</div>
- <div class="text-xs text-gray-400">${this._escapeHtml(user.email)}</div>
+ ${user.email ? `<div class="text-xs text-gray-400">${this._escapeHtml(user.email)}</div>` : ""}
</div>
</button>
`).join("")
diff --git a/app/services/codebase_import/user_matcher.rb b/app/services/codebase_import/user_matcher.rb
index 25916c8..5f0cdbd 100644
--- a/app/services/codebase_import/user_matcher.rb
+++ b/app/services/codebase_import/user_matcher.rb
@@ -61,7 +61,11 @@ class CodebaseImport::UserMatcher
# 2. Similar email addresses (same domain, from pre-loaded users)
if email.present?
domain = email.split('@').last
- similar_emails = active_users.select { |u| u.email != email && u.email&.end_with?("@#{domain}") }
+ # The email each member shows to others (User::EmailDisplay), not the
+ # login address: the preview names the member next to the match, which
+ # would confirm the domain of a hidden address. The exact match above
+ # stays on the login address, it is how an import finds the account.
+ similar_emails = active_users.select { |u| u.email != email && u.shown_email&.end_with?("@#{domain}") }
.first(3)
similar_emails.each do |user|
diff --git a/app/services/people/directory.rb b/app/services/people/directory.rb
index 194935d..6b42ceb 100644
--- a/app/services/people/directory.rb
+++ b/app/services/people/directory.rb
@@ -40,13 +40,14 @@ module People
end
# The line under the name, in the list and in the link dialog: function
- # and company of the row, else a member's email, else the salutation
- # (two contacts called "Müller" are "Frau" and "Herr"). A contact without
- # any has none (nil). A contact never shows an email here: the row's own
+ # and company of the row, else the email a member shows to others
+ # (User#shown_email, nil when they show none), else the salutation (two
+ # contacts called "Müller" are "Frau" and "Herr"). A contact without any
+ # has none (nil). A contact never shows an email here: the row's own
# email is a field of its page, not a label.
def detail
[person&.function, person&.company].compact_blank.join(' · ').presence ||
- (user&.email if member?) || person&.salutation
+ (user&.shown_email if member?) || person&.salutation
end
end
@@ -217,10 +218,12 @@ module People
@people ||= PersonPolicy::Scope.new(@viewer, Person).resolve
end
- # A member's email is the account's; an email left on a member row is not
- # shown, so it is not searched either.
+ # A member's email is the one they show to others (User#shown_email); a
+ # hidden login address and an email left on a member row are not shown, so
+ # they are not searched either: a search must not confirm that an address
+ # belongs to a member.
def matches?(entry)
- email = entry.member? ? entry.user.email : entry.person&.email
+ email = entry.member? ? entry.user.shown_email : entry.person&.email
addressed = [entry.person&.salutation, entry.plain_name].compact_blank.join(' ')
haystack = [addressed, entry.person&.function, entry.person&.department, entry.person&.company, email,
*PersonDetail.search_values(entry.person&.additional_details)]
diff --git a/app/services/people/lookup.rb b/app/services/people/lookup.rb
index 98e5cc7..e1f16ab 100644
--- a/app/services/people/lookup.rb
+++ b/app/services/people/lookup.rb
@@ -104,14 +104,15 @@ module People
}
end
- # The card of one person: the row plus how to reach them. A member's email is the
- # account's, as on the people page; phone, details and notes come from the row. The notes
+ # The card of one person: the row plus how to reach them. A member's email is the one
+ # they show to others (User#shown_email, nil when none), as on the people page; phone,
+ # details and notes come from the row. The notes
# as stored, nil when blank or when a member has no row.
def self.card(entry, notes: false)
person = entry.person
card = row(entry).merge(
salutation: person&.salutation,
- email: entry.member? ? entry.user.email : person&.email,
+ email: entry.member? ? entry.user.shown_email : person&.email,
phone: person&.phone,
additional_details: details(person)
)
diff --git a/app/views/organisations/codebase_import_files/preview_import.html.erb b/app/views/organisations/codebase_import_files/preview_import.html.erb
index 1ced596..4f8611e 100644
--- a/app/views/organisations/codebase_import_files/preview_import.html.erb
+++ b/app/views/organisations/codebase_import_files/preview_import.html.erb
@@ -110,7 +110,7 @@
<% end %>
<option value="create"><%= t('views.organisations.codebase_import_files.preview_import.action_create') %></option>
<% (mapping[:existing_matches] || []).reject { |m| m[:match_type] == :exact_email }.each do |match| %>
- <option value="map:<%= match[:user].id %>"><%= t('views.organisations.codebase_import_files.preview_import.action_map_to', email: match[:user].email) %></option>
+ <option value="map:<%= match[:user].id %>"><%= t('views.organisations.codebase_import_files.preview_import.action_map_to', email: [viewer_display_name(match[:user]), match[:user].shown_email].compact.join(' · ')) %></option>
<% end %>
<option value="skip"><%= t('views.organisations.codebase_import_files.preview_import.action_skip') %></option>
</select>
@@ -161,7 +161,7 @@
<div class="space-y-1">
<% mapping[:existing_matches].first(3).each do |match| %>
<div class="text-xs text-cream-900">
- <%= match[:user].email %>
+ <%= [viewer_display_name(match[:user]), match[:user].shown_email].compact.join(' · ') %>
<span class="text-cream-900 bg-gray-200 border border-stroke rounded px-1 py-0.5 ml-1 text-xs">
<%= match[:confidence].to_s.capitalize %>
</span>
diff --git a/app/views/organisations/memberships/_member.html.erb b/app/views/organisations/memberships/_member.html.erb
index a4ea70e..9c01143 100644
--- a/app/views/organisations/memberships/_member.html.erb
+++ b/app/views/organisations/memberships/_member.html.erb
@@ -14,7 +14,8 @@
<% if membership.user_id == current_user.id %><span class="members-state"><%= t('member_management.you') %></span><% end %>
<% unless membership.active? %><span class="members-state"><span class="members-status-dot"></span><%= t('member_management.blocked') %></span><% end %>
</div>
- <p class="truncate text-xs text-muted"><%= membership.user.email %></p>
+ <%# The email the member shows to others (User::EmailDisplay), also to an admin; none when they show none. %>
+ <% if (shown_email = membership.user.shown_email) %><p class="truncate text-xs text-muted"><%= shown_email %></p><% end %>
</div>
</div></td>
<td class="members-col-role">
diff --git a/app/views/organisations/memberships/_panel.html.erb b/app/views/organisations/memberships/_panel.html.erb
index b498b8f..bbf300f 100644
--- a/app/views/organisations/memberships/_panel.html.erb
+++ b/app/views/organisations/memberships/_panel.html.erb
@@ -5,7 +5,7 @@
</div>
<div class="flex items-center gap-[11px] pb-5 border-b border-cream-200">
<%= render Neo::Users::AvatarComponent.new(user: membership.user, size: :detail) %>
- <div class="min-w-0"><h3 class="text-[17px] font-semibold text-heading truncate"><%= viewer_display_name(membership.user) %></h3><p class="text-xs text-muted truncate"><%= membership.user.email %></p></div>
+ <div class="min-w-0"><h3 class="text-[17px] font-semibold text-heading truncate"><%= viewer_display_name(membership.user) %></h3><% if (shown_email = membership.user.shown_email) %><p class="text-xs text-muted truncate"><%= shown_email %></p><% end %></div>
</div>
<% if membership.errors.any? %><p class="members-danger py-3 text-sm" role="alert"><%= membership.errors.full_messages.to_sentence %></p><% end %>
<div class="members-setting"><span class="text-sm text-muted"><%= t('member_management.role') %></span><%= render 'role', membership: membership, location: 'panel' %></div>
diff --git a/app/views/organisations/people/_form.html.erb b/app/views/organisations/people/_form.html.erb
index f51f995..17544b8 100644
--- a/app/views/organisations/people/_form.html.erb
+++ b/app/views/organisations/people/_form.html.erb
@@ -72,7 +72,7 @@
<div class="people-form__field">
<%= f.label :email %>
<% if member %>
- <%= email_field_tag 'person_email_locked', member.email, id: 'person_email', readonly: true, disabled: true, autocomplete: 'off',
+ <%= email_field_tag 'person_email_locked', member.shown_email, id: 'person_email', readonly: true, disabled: true, autocomplete: 'off',
class: 'people-input people-input--locked' %>
<% else %>
<%= f.email_field :email, class: 'people-input', maxlength: Person::MAX_FIELD_LENGTH,
diff --git a/app/views/organisations/smart_folders/index.html.erb b/app/views/organisations/smart_folders/index.html.erb
index b46549e..e0b89a9 100644
--- a/app/views/organisations/smart_folders/index.html.erb
+++ b/app/views/organisations/smart_folders/index.html.erb
@@ -62,7 +62,7 @@
</span>
<% else %>
<span class="text-xs text-gray-500">
- <%= t('smart_folders.ownership.from', default: 'Von') %> <%= folder.user.email %>
+ <%= t('smart_folders.ownership.from', default: 'Von') %> <%= viewer_display_name(folder.user) %>
</span>
<% end %>
</div>
diff --git a/app/views/organisations/smart_folders/share.html.erb b/app/views/organisations/smart_folders/share.html.erb
index 7c3ba04..9a0c20e 100644
--- a/app/views/organisations/smart_folders/share.html.erb
+++ b/app/views/organisations/smart_folders/share.html.erb
@@ -3,7 +3,7 @@
<h2 class="text-2xl md:text-[1.6rem] font-semibold">
<%= t('.title', name: @smart_folder.name) %>
</h2>
-
+
<%= link_to organisation_smart_folder_path(current_organisation, @smart_folder), class: 'text-cobalt-600 hover:text-cobalt-800 flex items-center' do %>
<i class="bi bi-arrow-left me-1"></i> <%= t('generic.back_to_details', default: 'Zurück zum Ordner') %>
<% end %>
@@ -15,14 +15,14 @@
<h3 class="text-lg font-medium text-gray-900 mb-4">
<%= t('.add_new_share', default: 'Neue Freigabe hinzufügen') %>
</h3>
-
+
<%= form_with url: perform_share_organisation_smart_folder_path(current_organisation, @smart_folder), method: :post, data: { turbo: false }, class: 'space-y-4' do |form| %>
<div>
<%= form.label :share_user_ids, t('.select_users'), class: 'block text-sm font-medium text-gray-700 mb-1' %>
<%= form.select :share_user_ids,
- options_from_collection_for_select(@users_for_sharing, :id, :email),
+ options_for_select(@users_for_sharing.map { |user| [[viewer_display_name(user), user.shown_email].compact.join(' · '), user.id] }),
{ include_blank: t('helpers.select.prompt') },
- { multiple: true,
+ { multiple: true,
class: 'mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-cobalt-500 focus:border-cobalt-500 sm:text-sm rounded-md',
size: 6 } %>
<p class="mt-1 text-xs text-gray-500">
@@ -36,18 +36,18 @@
</h4>
<div class="space-y-2">
<div class="flex items-start">
- <%= form.check_box :share_can_edit,
- { class: 'h-4 w-4 text-cobalt-600 focus:ring-cobalt-500 border-gray-300 rounded mt-1' },
+ <%= form.check_box :share_can_edit,
+ { class: 'h-4 w-4 text-cobalt-600 focus:ring-cobalt-500 border-gray-300 rounded mt-1' },
'1', '0' %>
<div class="ml-3">
<%= form.label :share_can_edit, t('.can_edit'), class: 'text-sm text-gray-700 block' %>
<p class="text-xs text-gray-500"><%= t('.can_edit_hint', default: 'Benutzer können die Regeln und Einstellungen des Ordners bearbeiten') %></p>
</div>
</div>
-
+
<div class="flex items-start">
- <%= form.check_box :share_can_share,
- { class: 'h-4 w-4 text-cobalt-600 focus:ring-cobalt-500 border-gray-300 rounded mt-1' },
+ <%= form.check_box :share_can_share,
+ { class: 'h-4 w-4 text-cobalt-600 focus:ring-cobalt-500 border-gray-300 rounded mt-1' },
'1', '0' %>
<div class="ml-3">
<%= form.label :share_can_share, t('.can_share'), class: 'text-sm text-gray-700 block' %>
@@ -68,7 +68,7 @@
<h3 class="text-lg font-medium text-gray-900 mb-4">
<%= t('.shared_with') %>
</h3>
-
+
<% if @existing_shares.any? %>
<div class="divide-y divide-gray-200">
<% @existing_shares.each do |share| %>
@@ -79,7 +79,7 @@
<i class="bi bi-person-circle"></i>
</div>
<span class="text-gray-900 font-medium">
- <%= share.user.email %>
+ <%= [viewer_display_name(share.user), share.user.shown_email].compact.join(' · ') %>
</span>
</div>
<div class="mt-1 ml-6 flex space-x-2">
@@ -122,4 +122,4 @@
<%= link_to organisation_smart_folder_path(current_organisation, @smart_folder), class: 'text-cobalt-600 hover:text-cobalt-800 flex items-center' do %>
<i class="bi bi-arrow-left me-1"></i> <%= t('generic.back_to_details', default: 'Zurück zum Ordner') %>
<% end %>
-</div>
\ No newline at end of file
+</div>
diff --git a/app/views/organisations/smart_folders/share.turbo_stream.erb b/app/views/organisations/smart_folders/share.turbo_stream.erb
index c2e65c4..36f6bc1 100644
--- a/app/views/organisations/smart_folders/share.turbo_stream.erb
+++ b/app/views/organisations/smart_folders/share.turbo_stream.erb
@@ -3,8 +3,3 @@
<%= turbo_stream.prepend "flash" do %>
<%= render "layouts/flash" %> <%# Your default flash partial %>
<% end %>
-
-<%# Optional: re-render the list of shares %>
-<%#= turbo_stream.replace "shared-users-list" do %>
- <%#= render partial: "shared_users_list", locals: { smart_folder: @smart_folder, existing_shares: @smart_folder.smart_folder_shares.includes(:user).order('users.email') } %>
-<%# end %>
\ No newline at end of file
diff --git a/app/views/organisations/smart_folders/show.html.erb b/app/views/organisations/smart_folders/show.html.erb
index 78ed3a2..c77e03a 100644
--- a/app/views/organisations/smart_folders/show.html.erb
+++ b/app/views/organisations/smart_folders/show.html.erb
@@ -36,7 +36,7 @@
<div class="flex items-center">
<i class="bi bi-person me-2 text-gray-500"></i>
<span class="font-medium text-gray-700">
- <%= @smart_folder.user == current_user ? t('smart_folders.ownership.you', default: 'Sie') : @smart_folder.user.email %>
+ <%= @smart_folder.user == current_user ? t('smart_folders.ownership.you', default: 'Sie') : viewer_display_name(@smart_folder.user) %>
</span>
</div>
diff --git a/app/views/organisations/user_activities/index.html.erb b/app/views/organisations/user_activities/index.html.erb
index 103275b..6c7bc76 100644
--- a/app/views/organisations/user_activities/index.html.erb
+++ b/app/views/organisations/user_activities/index.html.erb
@@ -20,8 +20,9 @@
<h2 class="text-2xl font-bold mb-2">
<%= viewer_display_name(@user) %>
</h2>
- <p class="text-lg text-gray-600 mb-3"><%= @user.email %></p>
-
+ <%# The email the member shows to others (User::EmailDisplay), also on this admin page. %>
+ <% if @user.shown_email %><p class="text-lg text-gray-600 mb-3"><%= @user.shown_email %></p><% end %>
+
<!-- Status Badges -->
<div class="flex flex-wrap gap-2">
<% if @membership %>
@@ -57,7 +58,7 @@
<i class="bi bi-activity text-3xl text-cobalt-500"></i>
</div>
</div>
-
+
<div class="bg-surface-raised border border-slate-200 rounded-lg p-4 shadow-sm">
<div class="flex items-center justify-between">
<div>
@@ -67,7 +68,7 @@
<i class="bi bi-box-arrow-in-right text-3xl text-green-500"></i>
</div>
</div>
-
+
<div class="bg-surface-raised border border-slate-200 rounded-lg p-4 shadow-sm">
<div class="flex items-center justify-between">
<div>
@@ -79,7 +80,7 @@
<i class="bi bi-exclamation-triangle text-3xl text-red-500"></i>
</div>
</div>
-
+
<div class="bg-surface-raised border border-slate-200 rounded-lg p-4 shadow-sm">
<div class="flex items-center justify-between">
<div>
@@ -89,7 +90,7 @@
<i class="bi bi-shield-exclamation text-3xl text-yellow-500"></i>
</div>
</div>
-
+
<div class="bg-surface-raised border border-slate-200 rounded-lg p-4 shadow-sm">
<div class="flex items-center justify-between">
<div>
@@ -107,10 +108,10 @@
<div class="bg-surface-raised border border-slate-200 rounded-lg p-4 shadow-sm mb-6">
<%= form_with url: organisation_user_activities_path(@current_organisation), method: :get, local: true, class: "flex flex-wrap gap-4" do |f| %>
<%= hidden_field_tag :user_id, @user.id %>
-
+
<div class="flex-1 min-w-[200px]">
<%= f.label :category, t('.filter.category'), class: "block text-sm font-bold text-gray-700 mb-1" %>
- <%= f.select :category,
+ <%= f.select :category,
options_for_select([
[t('.filter.all'), ''],
[t('.filter.authentication'), 'auth'],
@@ -122,7 +123,7 @@
{},
class: "w-full px-3 py-2 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-cobalt-500" %>
</div>
-
+
<div class="flex-1 min-w-[200px]">
<%= f.label :status, t('.filter.status'), class: "block text-sm font-bold text-gray-700 mb-1" %>
<%= f.select :status,
@@ -135,21 +136,21 @@
{},
class: "w-full px-3 py-2 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-cobalt-500" %>
</div>
-
+
<div class="flex-1 min-w-[150px]">
<%= f.label :date_from, t('.filter.from'), class: "block text-sm font-bold text-gray-700 mb-1" %>
- <%= f.date_field :date_from,
+ <%= f.date_field :date_from,
value: params[:date_from],
class: "w-full px-3 py-2 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-cobalt-500" %>
</div>
-
+
<div class="flex-1 min-w-[150px]">
<%= f.label :date_to, t('.filter.to'), class: "block text-sm font-bold text-gray-700 mb-1" %>
<%= f.date_field :date_to,
value: params[:date_to],
class: "w-full px-3 py-2 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-cobalt-500" %>
</div>
-
+
<div class="flex items-end gap-2">
<%# P4/D1: filter actions as ButtonComponent. Apply = primary (the region's one action, E1). %>
<%= render Neo::Buttons::ButtonComponent.new(
@@ -272,7 +273,7 @@
</div>
<% end %>
</div>
-
+
<!-- Pagination -->
<% if @pagy && @pagy.pages > 1 %>
<div class="mt-6 pt-4 border-t-2 border-gray-200">
@@ -288,4 +289,4 @@
<% end %>
</div>
</div>
-</div>
\ No newline at end of file
+</div>
diff --git a/spec/architecture/shown_email_guard_spec.rb b/spec/architecture/shown_email_guard_spec.rb
new file mode 100644
index 0000000..d829dd6
--- /dev/null
+++ b/spec/architecture/shown_email_guard_spec.rb
@@ -0,0 +1,109 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+# What: code that shows or searches a member's email for OTHER people reads it
+# through User#shown_email (User::EmailDisplay), never through a bare `.email`.
+# Why: a member chooses which email the others see (the login address, a contact
+# address, or none). Until 29.10.2026 every place read the login address
+# directly: the people directory, the assistant/MCP/REST card, the members page
+# (for every member, customers included), smart folder sharing, the subscriber
+# picker, the activity page and the import preview. A choice that each of
+# those has to remember is not a choice, so the bare read is refused here.
+#
+# A tripwire, not a proof: it reads `<receiver>.email` / `<receiver>&.email` in
+# Ruby, ERB and JavaScript. It does not see an email reached through `send`,
+# `[:email]`, `pluck(:email)`, `as_json` of a whole user, or a SQL fragment.
+module ShownEmailGuard
+ ROOTS = %w[app/controllers app/services app/views app/helpers app/components app/javascript].freeze
+
+ # The account owner's own view, Lalabase's own mail, Devise and the instance
+ # admin area keep the login address on purpose (User::EmailDisplay header).
+ EXCLUDED = %r{\Aapp/(?:views|controllers|services)/admin/|\Aapp/views/devise/|\Aapp/controllers/users/|
+ mailers?/|_mailer|\Aapp/views/user_data_exports/|\Aapp/services/user_data_exports/}x
+
+ # Receivers whose `.email` is not a member's login address shown to others.
+ SAFE_RECEIVERS = {
+ 'person' => 'a person row of the directory (a contact typed by colleagues), not an account',
+ 'invitation' => 'the address an invitation was sent to, shown to the inviter before any account exists',
+ 'current_user' => "the viewer's own account",
+ 'placeholders' => 'part of an i18n key (views.organisations.people.form.placeholders.email)'
+ }.freeze
+
+ # Shrink-only: [file, receiver] and why that read is not a member's address shown
+ # to others. An entry without a finding left fails as well.
+ ALLOWED = {
+ ['app/controllers/api/v1/me_controller.rb', 'user'] =>
+ "GET /api/v1/me answers the token holder's own account",
+ ['app/services/codebase_import/user_matcher.rb', 'u'] =>
+ 'the exact match of an import finds the account by its login address; the preview shows the shown email',
+ ['app/services/codebase_import/ticket_update_importer.rb', 'new_assignee'] =>
+ 'a debug log line on the server, never rendered',
+ ['app/controllers/organisations/documents_controller.rb', 'users'] =>
+ 'a whitelisted SQL sort column name, not a value shown to anyone',
+ ['app/services/notifications/score_calculator.rb', '@recipient'] =>
+ "compares the recipient's own address with a rule value, nothing is shown",
+ ['app/javascript/controllers/subscriber_picker_controller.js', 'user'] =>
+ 'reads the JSON field `email`, which the server fills with User#shown_email'
+ }.freeze
+
+ CALL = /(?<receiver>@?[A-Za-z_]\w*)(?:\.|&\.)email\b(?![\w?!=])/
+
+ def self.files
+ ROOTS.flat_map { |root| Dir[Rails.root.join(root, '**', '*.{rb,erb,js}')] }
+ .map { |path| Pathname(path).relative_path_from(Rails.root).to_s }
+ .reject { |path| path.match?(EXCLUDED) }
+ .sort
+ end
+
+ # [[file, receiver, line number, text]] of every bare read
+ def self.findings
+ files.flat_map do |file|
+ File.readlines(Rails.root.join(file)).each_with_index.flat_map do |line, index|
+ next [] if line.match?(%r{\A\s*(?:#|<%#|//)})
+
+ line.to_enum(:scan, CALL).map { Regexp.last_match[:receiver] }
+ .reject { |receiver| SAFE_RECEIVERS.key?(receiver.delete_prefix('@')) }
+ .map { |receiver| [file, receiver, index + 1, line.strip] }
+ end
+ end
+ end
+end
+
+RSpec.describe ShownEmailGuard, :ci_guard do
+ it 'finds every bare member email outside the shown email' do
+ unexpected = described_class.findings.reject { |file, receiver, *| described_class::ALLOWED.key?([file, receiver]) }
+
+ expect(unexpected).to be_empty, lambda {
+ lines = unexpected.map { |file, _receiver, line, text| " #{file}:#{line}: #{text}" }.join("\n")
+ "A member's email shown to others goes through User#shown_email, not `.email`:\n#{lines}"
+ }
+ end
+
+ it 'keeps no allow-list entry without a finding' do
+ found = described_class.findings.to_set { |file, receiver, *| [file, receiver] }
+ stale = described_class::ALLOWED.keys.reject { |key| found.include?(key) }
+
+ expect(stale).to be_empty, "Remove the stale entries: #{stale.inspect}"
+ end
+
+ it 'reads the places it promises to read' do
+ files = described_class.files
+
+ expect(files).to include('app/views/organisations/memberships/_member.html.erb',
+ 'app/services/people/directory.rb', 'app/services/people/lookup.rb',
+ 'app/javascript/controllers/subscriber_picker_controller.js')
+ expect(files).not_to include('app/views/devise/registrations/edit.html.erb')
+ end
+
+ it 'sees a bare read in Ruby, ERB and JavaScript, and lets the shown email pass' do
+ probe = ->(text) { text.to_enum(:scan, described_class::CALL).map { Regexp.last_match[:receiver] } }
+
+ expect(probe.call('<%= membership.user.email %>')).to eq(['user'])
+ expect(probe.call('entry.user&.email')).to eq(['user'])
+ expect(probe.call('${member.email}')).to eq(['member'])
+ expect(probe.call('membership.user.shown_email')).to eq([])
+ expect(probe.call('user.email_visibility')).to eq([])
+ expect(probe.call('user.email?')).to eq([])
+ end
+end
diff --git a/spec/requests/api/mcp_people_spec.rb b/spec/requests/api/mcp_people_spec.rb
index 1e3a83c..a39608b 100644
--- a/spec/requests/api/mcp_people_spec.rb
+++ b/spec/requests/api/mcp_people_spec.rb
@@ -203,6 +203,16 @@ RSpec.describe 'MCP people tools', :ci_guard, type: :request do
expect(data(person("member:#{colleague.id}"))).to include('name' => 'Carl Kollege', 'email' => '[email protected]')
end
+ it 'answers the email a member shows to others, never a hidden login address' do
+ colleague.update!(email_visibility: 'contact', contact_email: '[email protected]')
+ expect(data(person("member:#{colleague.id}"))).to include('name' => 'Carl Kollege', 'email' => '[email protected]')
+
+ colleague.update!(email_visibility: 'none')
+ result = person("member:#{colleague.id}")
+ expect(data(result)).to include('name' => 'Carl Kollege', 'email' => nil)
+ expect(text(result)).not_to include('[email protected]')
+ end
+
# Like get_ticket on this surface: a record that is not there is an empty answer, the same
# for a missing, a foreign and an invisible id; not_found is kept for the organisation.
it 'answers a missing, a foreign and an invisible person alike' do
diff --git a/spec/requests/api/v1/people_spec.rb b/spec/requests/api/v1/people_spec.rb
index 6cc7722..bf0440b 100644
--- a/spec/requests/api/v1/people_spec.rb
+++ b/spec/requests/api/v1/people_spec.rb
@@ -255,6 +255,17 @@ RSpec.describe 'API V1 people', :ci_guard, type: :request do
'email' => '[email protected]', 'notes' => 'Bevorzugt Mail.')
end
+ it 'answers the email a member shows to others, never a hidden login address' do
+ colleague.update!(email_visibility: 'contact', contact_email: '[email protected]')
+ show("member:#{colleague.id}")
+ expect(body['data']).to include('name' => 'Carl Kollege', 'email' => '[email protected]')
+
+ colleague.update!(email_visibility: 'none')
+ show("member:#{colleague.id}")
+ expect(body['data']).to include('name' => 'Carl Kollege', 'email' => nil)
+ expect(response.body).not_to include('[email protected]')
+ end
+
it 'answers a missing, a foreign and an invisible person with the same 404' do
ids = ["person:#{SecureRandom.uuid}", "member:#{SecureRandom.uuid}", "person:#{foreign_contact.id}",
"person:#{hidden_row.id}", "member:#{stranger.id}"]
diff --git a/spec/requests/organisations/shown_email_spec.rb b/spec/requests/organisations/shown_email_spec.rb
new file mode 100644
index 0000000..14bf9e2
--- /dev/null
+++ b/spec/requests/organisations/shown_email_spec.rb
@@ -0,0 +1,191 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+# A member chooses which email the others see (User::EmailDisplay): the login
+# address, a contact address, or none. Every page inside an organisation that
+# shows or searches a member's email follows that choice, also for an
+# organisation admin. Each check proves the page rendered (a positive anchor)
+# before it claims that the login address is absent.
+RSpec.describe 'The email a member shows to others', :ci_guard, type: :request do
+ let(:organisation) { create(:organisation) }
+ let(:project) { ActsAsTenant.with_tenant(organisation) { create(:project, organisation: organisation) } }
+
+ before { ActsAsTenant.current_tenant = organisation }
+ after { ActsAsTenant.current_tenant = nil }
+
+ let(:account_admin_role) do
+ ActsAsTenant.with_tenant(organisation) { create(:role, organisation: organisation, title: Role::ACCOUNT_ADMIN_TITLE) }
+ end
+
+ def member(first_name, email, **choice)
+ user = create(:user, first_name: first_name, last_name: 'Beispiel', email: email, **choice)
+ create(:membership, user: user, organisation: organisation, role: account_admin_role, active: true)
+ user
+ end
+
+ let!(:admin) { member('Adele', '[email protected]') }
+ let!(:lena) { member('Lena', '[email protected]', email_visibility: 'contact', contact_email: '[email protected]') }
+ let!(:nina) { member('Nina', '[email protected]', email_visibility: 'none') }
+
+ before { sign_in admin }
+
+ def expect_no_hidden_login_address(body)
+ expect(body).not_to include('lena-login')
+ expect(body).not_to include('nina-login')
+ end
+
+ describe 'the people page' do
+ it 'lists a member with the chosen email, and nothing for one who shows none' do
+ get organisation_people_path(organisation)
+
+ expect(response).to have_http_status(:ok)
+ expect(response.body).to include('Lena', 'Nina', '[email protected]')
+ expect_no_hidden_login_address(response.body)
+ end
+
+ it 'links the chosen email in the lane of a member' do
+ get organisation_people_path(organisation, member_id: lena.id),
+ headers: { 'Turbo-Frame' => Organisations::PeopleController::DETAIL_FRAME_ID }
+
+ expect(response).to have_http_status(:ok)
+ expect(response.body).to include('mailto:[email protected]')
+ expect_no_hidden_login_address(response.body)
+ end
+
+ it 'shows no email in the lane of a member who shows none' do
+ get organisation_people_path(organisation, member_id: nina.id),
+ headers: { 'Turbo-Frame' => Organisations::PeopleController::DETAIL_FRAME_ID }
+
+ expect(response).to have_http_status(:ok)
+ expect(response.body).to include('Nina')
+ expect(response.body).not_to include('mailto:')
+ expect_no_hidden_login_address(response.body)
+ end
+
+ it 'finds a member by the shown email, never by a hidden login address' do
+ get organisation_people_path(organisation, q: 'lena.team')
+ expect(response.body).to include('[email protected]')
+
+ get organisation_people_path(organisation, q: 'lena-login')
+ expect(response).to have_http_status(:ok)
+ expect(response.body).not_to include('[email protected]')
+
+ get organisation_people_path(organisation, q: 'nina-login')
+ expect(response).to have_http_status(:ok)
+ expect(response.body).not_to include('Nina Beispiel')
+ end
+ end
+
+ describe 'the members page' do
+ it 'shows the chosen email in the rows, to an admin too' do
+ get organisation_memberships_path(organisation)
+
+ expect(response).to have_http_status(:ok)
+ expect(response.body).to include('Lena', 'Nina', '[email protected]', '[email protected]')
+ expect_no_hidden_login_address(response.body)
+ end
+
+ it 'shows the chosen email in the side panel of a member' do
+ membership = Membership.find_by!(user: lena, organisation: organisation)
+ get organisation_memberships_path(organisation, membership_id: membership.id)
+
+ expect(response).to have_http_status(:ok)
+ expect(response.body).to include('[email protected]')
+ expect_no_hidden_login_address(response.body)
+ end
+
+ it 'finds a member by the shown email, never by a hidden login address' do
+ get organisation_memberships_path(organisation, q: 'lena.team')
+ expect(response.body).to include('[email protected]')
+
+ get organisation_memberships_path(organisation, q: 'lena-login')
+ expect(response).to have_http_status(:ok)
+ expect(response.body).not_to include('[email protected]')
+ end
+ end
+
+ describe 'sharing a smart folder' do
+ let(:folder) do
+ ActsAsTenant.with_tenant(organisation) do
+ create(:smart_folder, user: admin, organisation: organisation, project: project, target_object_type: 'Ticket')
+ end
+ end
+
+ before do
+ [admin, lena, nina].each { |user| create(:project_permission, user: user, project: project, tickets_access: 'read_write') }
+ end
+
+ it 'offers the members by name and shown email' do
+ get share_organisation_smart_folder_path(organisation, folder)
+
+ expect(response).to have_http_status(:ok)
+ expect(response.body).to include('Lena Beispiel', 'Nina Beispiel')
+ expect_no_hidden_login_address(response.body)
+ end
+
+ it 'names the members a folder is shared with without a hidden login address' do
+ ActsAsTenant.with_tenant(organisation) do
+ create(:smart_folder_share, smart_folder: folder, user: lena)
+ create(:smart_folder_share, smart_folder: folder, user: nina)
+ end
+
+ get share_organisation_smart_folder_path(organisation, folder)
+
+ expect(response).to have_http_status(:ok)
+ expect(response.body).to include('[email protected]')
+ expect_no_hidden_login_address(response.body)
+ end
+
+ it 'names the owner of a shared folder without a hidden login address' do
+ foreign = ActsAsTenant.with_tenant(organisation) do
+ create(:smart_folder, user: lena, organisation: organisation, project: project, target_object_type: 'Ticket').tap do |f|
+ create(:smart_folder_share, smart_folder: f, user: admin)
+ end
+ end
+
+ get organisation_smart_folder_path(organisation, foreign)
+
+ expect(response).to have_http_status(:ok)
+ expect(response.body).to include(foreign.name)
+ expect_no_hidden_login_address(response.body)
+ end
+ end
+
+ describe 'the subscriber picker of a ticket' do
+ let(:ticket) { ActsAsTenant.with_tenant(organisation) { create(:ticket, project: project, creator: admin) } }
+ let(:path) { available_users_organisation_project_ticket_subscription_path(organisation, project, ticket) }
+
+ it 'answers the shown email, null for a member who shows none' do
+ get path, as: :json
+
+ expect(response).to have_http_status(:ok)
+ rows = response.parsed_body.index_by { |row| row['id'] }
+ expect(rows.fetch(lena.id)['email']).to eq('[email protected]')
+ expect(rows.fetch(nina.id)['email']).to be_nil
+ expect_no_hidden_login_address(response.body)
+ end
+
+ it 'searches the shown email, never a hidden login address' do
+ get path, params: { q: 'lena.team' }, as: :json
+ expect(response.parsed_body.pluck('id')).to include(lena.id)
+
+ get path, params: { q: 'lena-login' }, as: :json
+ expect(response).to have_http_status(:ok)
+ expect(response.parsed_body).to eq([])
+
+ get path, params: { q: 'nina-login' }, as: :json
+ expect(response.parsed_body).to eq([])
+ end
+ end
+
+ describe 'the activity page of a member' do
+ it 'shows the chosen email under the name' do
+ get organisation_user_activities_path(organisation, user_id: lena.id)
+
+ expect(response).to have_http_status(:ok)
+ expect(response.body).to include('[email protected]')
+ expect_no_hidden_login_address(response.body)
+ end
+ end
+end
diff --git a/spec/services/codebase_import/user_matcher_spec.rb b/spec/services/codebase_import/user_matcher_spec.rb
index f0ec36e..72fdb96 100644
--- a/spec/services/codebase_import/user_matcher_spec.rb
+++ b/spec/services/codebase_import/user_matcher_spec.rb
@@ -90,6 +90,17 @@ RSpec.describe CodebaseImport::UserMatcher do
expect(similar_matches.first[:confidence]).to eq(:medium)
expect(similar_matches.first[:reason]).to include('example.com')
end
+
+ # The domain of a hidden login address is not offered: the preview would
+ # name the member next to it and so confirm where they sign in.
+ it 'compares the email each member shows, never a hidden login address' do
+ domain_user.update!(email_visibility: 'none')
+ existing_user.update!(email_visibility: 'contact', contact_email: '[email protected]')
+
+ similar = matcher.send(:find_potential_matches, user_data).select { |m| m[:match_type] == :similar_email }
+
+ expect(similar.map { |m| m[:user] }).to contain_exactly(existing_user)
+ end
end
context 'with similar names' do
diff --git a/spec/services/people/directory_spec.rb b/spec/services/people/directory_spec.rb
index 39d85a4..05c9d1e 100644
--- a/spec/services/people/directory_spec.rb
+++ b/spec/services/people/directory_spec.rb
@@ -91,6 +91,21 @@ RSpec.describe People::Directory, :ci_guard do
expect(names(entries(query: 'versteckt'))).to eq([])
end
+ # The member chooses which email the others see (User::EmailDisplay). A search
+ # must not confirm a hidden login address.
+ it 'searches the email a member shows, never a hidden login address' do
+ colleague.update!(email_visibility: 'contact', contact_email: '[email protected]')
+
+ expect(names(entries(query: 'carl.team'))).to eq(['Carl Kollege'])
+ expect(names(entries(query: colleague.email))).to eq([])
+ end
+
+ it 'finds no email of a member who shows none' do
+ colleague.update!(email_visibility: 'none')
+
+ expect(names(entries(query: colleague.email))).to eq([])
+ end
+
# One directory per example: each call resolves the viewer's reach once, and
# Prosopite would read a second call as an N+1.
{
@@ -345,6 +360,16 @@ RSpec.describe People::Directory, :ci_guard do
expect(entry(kind: :contact, person: build(:person, email: '[email protected]', **bare)).detail).to be_nil
end
+ it 'is the email a member shows to others, and falls through when they show none' do
+ bare = { function: nil, company: nil }
+ contact = build(:user, email: '[email protected]', email_visibility: 'contact', contact_email: '[email protected]')
+ hidden = build(:user, email: '[email protected]', email_visibility: 'none')
+
+ expect(entry(kind: :member, user: contact).detail).to eq('[email protected]')
+ expect(entry(kind: :member, user: hidden).detail).to be_nil
+ expect(entry(kind: :member, user: hidden, person: build(:person, salutation: 'Herr', **bare)).detail).to eq('Herr')
+ end
+
# Two contacts named "Müller" without function or company: the salutation
# tells them apart in the list and in the link dialog.
it 'is the salutation of a row without function and company' do
diff --git a/spec/services/people/lookup_spec.rb b/spec/services/people/lookup_spec.rb
index 69146cf..228587b 100644
--- a/spec/services/people/lookup_spec.rb
+++ b/spec/services/people/lookup_spec.rb
@@ -250,6 +250,15 @@ RSpec.describe People::Lookup, :ci_guard do
expect(card).to include(id: "member:#{colleague.id}", name: 'Carl Kollege', email: '[email protected]',
notes: 'Bevorzugt Mail.')
end
+
+ # One card for the assistant, MCP and REST: each answers the email the member shows.
+ it 'carries the email a member shows to others, nil when they show none' do
+ colleague.update!(email_visibility: 'contact', contact_email: '[email protected]')
+ expect(described_class.card(lookup.entry("member:#{colleague.id}"))[:email]).to eq('[email protected]')
+
+ colleague.update!(email_visibility: 'none')
+ expect(described_class.card(lookup.entry("member:#{colleague.id}"))[:email]).to be_nil
+ end
end
# E1 of S3b: the directory and the last contact read across the whole organisation, so only