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.

Choose the email the others see in the display settings

Guido Boyke7fdfbcec12d4
diff --git a/.github/workflows/guards.yml b/.github/workflows/guards.yml
index 527fc14..43a07d2 100644
--- a/.github/workflows/guards.yml
+++ b/.github/workflows/guards.yml
@@ -333,6 +333,7 @@ jobs:
spec/models/person_spec.rb
spec/requests/organisations/people_spec.rb
spec/requests/organisations/shown_email_spec.rb
+ spec/requests/user_preferences_email_visibility_spec.rb
spec/services/people/directory_spec.rb
spec/services/people/contacts_spec.rb
spec/services/people/lookup_spec.rb
diff --git a/app/controllers/user_preferences_controller.rb b/app/controllers/user_preferences_controller.rb
index ae2650f..bd7b7de 100644
--- a/app/controllers/user_preferences_controller.rb
+++ b/app/controllers/user_preferences_controller.rb
@@ -42,6 +42,9 @@ class UserPreferencesController < ApplicationController
# submit can carry both; a failed picture keeps the section rendered with
# the model's own error message.
return if section == 'display' && user_param_hash? && !apply_avatar_update
+ # Which email the others see (User::EmailDisplay): a column on users, saved
+ # here and not in the Devise profile for the same reason as the picture.
+ return if section == 'display' && user_param_hash? && !apply_email_visibility_update
# Handle language preference separately
if section == 'language' && user_param_hash? && params[:user].key?(:language_preference)
@@ -104,6 +107,23 @@ class UserPreferencesController < ApplicationController
permitted[:avatar] = UserAvatars::CropUpload.call(upload: permitted[:avatar], crop: crop) if permitted[:avatar].present?
return true if current_user.update(permitted)
+ render_display_errors
+ end
+
+ # Which email the others see (User::EmailDisplay). Only these two columns: the
+ # login address and the password stay behind the Devise profile's
+ # current-password gate. Returns true when the rest of the update may proceed.
+ def apply_email_visibility_update
+ permitted = params.require(:user).permit(:email_visibility, :contact_email)
+ return true if permitted.empty?
+ return true if current_user.update(permitted)
+
+ render_display_errors
+ end
+
+ # The display section again, with the model's own error messages (422).
+ # Returns false, the answer of a refused update.
+ def render_display_errors
# respond_to, not a bare render: this controller answers JSON too (see the
# preferences branch above), and `render 'display'` on a JSON request looks
# for display.json and raises MissingTemplate — a 500 exactly where the
diff --git a/app/models/CLAUDE.md b/app/models/CLAUDE.md
index 4d7bdba..de628a0 100644
--- a/app/models/CLAUDE.md
+++ b/app/models/CLAUDE.md
@@ -1,4 +1,4 @@
-# Karte: app/models (Stand: 2026-10-28)
+# Karte: app/models (Stand: 2026-10-29)
~80 Modelle liegen flach in diesem Verzeichnis; Namespaces existieren nur für `admin/`,
`knowledge/`, `overview/`, `smart_folders/`, `time_sessions/`, `user/`. Die Domänen-Zugehörigkeit ist am
@@ -6,7 +6,11 @@ Verzeichnis-Layout nicht ablesbar — diese Karte gruppiert sie:
* **Kern/Tenancy**: `organisation` (= Tenant), `project`, `user` (+ `user/*` — Split-Vertrag
in den Kommentaren von `user.rb`, **Include-Reihenfolge ist load-bearing!**;
- Namens-Rendering hat EINEN Owner: `user/name_display.rb`), `membership`,
+ Namens-Rendering hat EINEN Owner: `user/name_display.rb`; welche E-Mail andere sehen
+ (Login-Adresse, Kontakt-Adresse oder keine, `email_visibility`) EINEN Owner:
+ `user/email_display.rb` (`#shown_email`, `.matching_shown_email`), Wächter
+ `spec/architecture/shown_email_guard_spec.rb` gegen ein rohes Mitglieds-`.email`; Anmeldung,
+ Mails und `/admin` behalten `email`), `membership`,
`role`, `permission`, `project_permission`, `invitation`, `account` (Billing-Ebene ÜBER Orgs),
`current` (`Current.user` = Audit-Actor der Activity-Kette)
* **Tickets**: `ticket`, `ticket_assignment`, `ticket_attribute_definition`, `ticket_document`,
diff --git a/app/services/CLAUDE.md b/app/services/CLAUDE.md
index 3339160..1ace613 100644
--- a/app/services/CLAUDE.md
+++ b/app/services/CLAUDE.md
@@ -163,7 +163,9 @@ Verzeichnis-Übersicht (Auswahl):
* `people/` — `directory.rb`, das Lese-Objekt der Personenliste (seit 26.10.2026): Mitglieder
über `MembershipPolicy::Scope` (dieselbe Reichweite wie die Mitgliederseite), dazu die
Zeilen ohne aktives Mitglied als Kontakte; Suche in Ruby über `PersonName.normalize`.
- Rechte nur über `PersonPolicy`, keine eigene Regel daneben.
+ Rechte nur über `PersonPolicy`, keine eigene Regel daneben. Die E-Mail eines Mitglieds
+ (Zeile unter dem Namen, Suche, Karte in `lookup.rb`) ist immer `User#shown_email`: eine
+ verborgene Login-Adresse wird weder gezeigt noch gesucht (29.10.2026).
`contacts.rb` (S2a, 26.10.2026): Meetings einer Person (`person_id` ODER `user_id` des
Mitglieds) und „Letzter Kontakt“ einer ganzen Liste in fester Abfragezahl. Lesbar nur über
`MeetingPolicy::Scope`, `TicketPolicy::Scope`, `Post.readable_by` und `Activity.feed`; bei
diff --git a/app/views/user_preferences/display.html.erb b/app/views/user_preferences/display.html.erb
index 3235811..8529c48 100644
--- a/app/views/user_preferences/display.html.erb
+++ b/app/views/user_preferences/display.html.erb
@@ -70,6 +70,30 @@
<% end %>
</div>
+ <%# Which email the others see (User::EmailDisplay): the login address,
+ a separate contact address, or none. A column on users, saved by
+ UserPreferencesController#apply_email_visibility_update without the
+ current password; signing in and Lalabase's mail keep the login address. %>
+ <div>
+ <span class="block text-sm font-bold mb-2 text-cream-900"><%= t('user_preferences.edit.display.email_visibility.label') %></span>
+ <div class="space-y-2">
+ <% User::EmailDisplay::EMAIL_VISIBILITIES.each do |choice| %>
+ <label class="flex items-center gap-3 rounded border border-cream-300 bg-surface-raised px-4 py-3 cursor-pointer hover:border-ink transition-all">
+ <%= radio_button_tag 'user[email_visibility]', choice, @user.email_visibility == choice %>
+ <span class="text-sm text-cream-900"><%= t("user_preferences.edit.display.email_visibility.#{choice}", email: @user.email) %></span>
+ </label>
+ <% end %>
+ </div>
+ <div class="mt-3">
+ <%= label_tag 'user_contact_email', t('user_preferences.edit.display.email_visibility.contact_label'), class: 'block text-sm font-bold mb-1 text-cream-900' %>
+ <%= email_field_tag 'user[contact_email]', @user.contact_email, id: 'user_contact_email', autocomplete: 'email',
+ maxlength: User::EmailDisplay::MAX_CONTACT_EMAIL_LENGTH,
+ class: 'block w-full rounded border border-cream-300 bg-surface-raised px-3 py-2 text-sm text-cream-900' %>
+ <p class="text-xs text-cream-600 mt-1"><%= t('user_preferences.edit.display.email_visibility.contact_hint') %></p>
+ </div>
+ <p class="text-xs text-cream-600 mt-2"><%= t('user_preferences.edit.display.email_visibility.description') %></p>
+ </div>
+
<!-- Name display mode -->
<div>
<span class="block text-sm font-bold mb-2 text-cream-900"><%= t('user_preferences.edit.display.name_display.label') %></span>
diff --git a/config/locales/de.yml b/config/locales/de.yml
index c3fb11a..8cfd8d8 100644
--- a/config/locales/de.yml
+++ b/config/locales/de.yml
@@ -3023,13 +3023,21 @@ de:
zu verwenden
label: Globales Format für alle Bereiche verwenden
display:
- intro: "Das Profilbild wird bei Kommentaren, Listen und Zuweisungen immer angezeigt. Hier wählst du zusätzlich, wie Namen für dich geschrieben werden. Beides gilt nur für deine eigene Ansicht."
+ intro: "Profilbild und E-Mail sehen auch andere in deinen Organisationen. Wie Namen geschrieben werden, gilt nur für deine eigene Ansicht."
avatar:
label: Profilbild
hint: PNG, JPEG oder WebP, maximal %{max_megabytes} MB. Wird immer neben deinem Namen angezeigt, z. B. bei Kommentaren und in Listen; ohne Bild stehen dort deine Initialen.
remove: Profilbild entfernen
crop_hint: "Ausschnitt wählen: Bild mit der Maus verschieben, Regler zoomt. Gespeichert wird der sichtbare Ausschnitt."
zoom_label: Zoom
+ email_visibility:
+ label: E-Mail für andere
+ login: "Meine Login-Adresse (%{email})"
+ contact: Eine andere Adresse
+ none: Keine E-Mail zeigen
+ contact_label: Andere Adresse
+ contact_hint: Wird nicht bestätigt und bekommt keine Mails von Lalabase.
+ description: "Diese E-Mail sehen andere in allen deinen Organisationen: im Personen-Verzeichnis, auf der Mitglieder-Seite, beim Assistenten und über die Schnittstellen. Anmelden und Mails von Lalabase laufen weiter über deine Login-Adresse."
name_display:
label: Schreibweise von Benutzernamen
full: Voller Name
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 96c07c1..93bd228 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -2776,13 +2776,21 @@ en:
description: Enable this option to use the global format everywhere
label: Use global format for all areas
display:
- intro: "The profile picture is always shown next to comments, lists and assignments. Here you additionally choose how names are spelled for you. Both only affect your own view."
+ intro: "Others in your organisations see your profile picture and your email. How names are spelled only affects your own view."
avatar:
label: Profile picture
hint: PNG, JPEG or WebP, up to %{max_megabytes} MB. Always shown next to your name, e.g. on comments and in lists; without a picture your initials appear there.
remove: Remove profile picture
crop_hint: "Frame the picture: drag to move, the slider zooms. The visible framing is what gets saved."
zoom_label: Zoom
+ email_visibility:
+ label: Email shown to others
+ login: "My login address (%{email})"
+ contact: Another address
+ none: Show no email
+ contact_label: Other address
+ contact_hint: Not confirmed, and Lalabase sends no mail to it.
+ description: "Others see this email in all your organisations: in the people directory, on the members page, in the assistant and through the APIs. Signing in and mail from Lalabase still use your login address."
name_display:
label: Name spelling
full: Full name
diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb
index f66393b..ad27c18 100644
--- a/spec/mailers/notification_mailer_spec.rb
+++ b/spec/mailers/notification_mailer_spec.rb
@@ -42,6 +42,14 @@ RSpec.describe NotificationMailer, type: :mailer do
it 'is addressed to the recipient' do
expect(described_class.index_completed(notification('index_completed')).to).to eq(['[email protected]'])
end
+
+ # The contact address is only shown to others (User::EmailDisplay); Lalabase
+ # never mails to it, whatever the member chose.
+ it 'goes to the login address, also when the member shows a contact address' do
+ recipient.update!(email_visibility: 'contact', contact_email: '[email protected]')
+
+ expect(described_class.index_completed(notification('index_completed')).to).to eq(['[email protected]'])
+ end
end
describe '#tickets_bulk_changed' do
diff --git a/spec/requests/user_preferences_email_visibility_spec.rb b/spec/requests/user_preferences_email_visibility_spec.rb
new file mode 100644
index 0000000..89dbed1
--- /dev/null
+++ b/spec/requests/user_preferences_email_visibility_spec.rb
@@ -0,0 +1,86 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+# Which email the others see (User::EmailDisplay) is chosen in the display
+# section of the settings, next to the profile picture: like the picture it
+# grants nothing, so it is saved without the current password (the Devise
+# profile demands it for every change). Login address and password stay behind
+# that gate.
+RSpec.describe 'User preferences: the email the others see', :ci_guard, type: :request do
+ let(:user) { create(:user, email: '[email protected]', password: 'password123') }
+
+ before { sign_in user }
+
+ def save(**fields)
+ patch user_preferences_path, params: { current_section: 'display', user: fields }
+ end
+
+ it 'offers the three choices and the contact address in the display section' do
+ get display_user_preferences_path
+
+ expect(response).to have_http_status(:ok)
+ User::EmailDisplay::EMAIL_VISIBILITIES.each do |choice|
+ expect(response.body).to include(%(value="#{choice}"))
+ expect(response.body).to include(CGI.escapeHTML(I18n.t("user_preferences.edit.display.email_visibility.#{choice}",
+ email: '[email protected]')))
+ end
+ expect(response.body).to include('name="user[contact_email]"')
+ expect(response.body).to include('value="login" checked="checked"')
+ end
+
+ it 'saves a contact address without the current password' do
+ save(email_visibility: 'contact', contact_email: '[email protected]')
+
+ expect(response).to redirect_to(display_user_preferences_path)
+ expect(user.reload).to have_attributes(email_visibility: 'contact', contact_email: '[email protected]',
+ email: '[email protected]')
+ end
+
+ it 'saves no email at all and keeps a stored contact address' do
+ user.update!(email_visibility: 'contact', contact_email: '[email protected]')
+
+ save(email_visibility: 'none', contact_email: '[email protected]')
+
+ expect(user.reload).to have_attributes(email_visibility: 'none', contact_email: '[email protected]')
+ end
+
+ it 'refuses an invalid address and renders the section with the reason' do
+ save(email_visibility: 'contact', contact_email: 'team@')
+
+ expect(response).to have_http_status(:unprocessable_content)
+ expect(response.body).to include(I18n.t('user_preferences.edit.display.email_visibility.label'))
+ expect(response.body).to include('team@')
+ expect(user.reload).to have_attributes(email_visibility: 'login', contact_email: nil)
+ end
+
+ it 'refuses the contact choice without an address' do
+ save(email_visibility: 'contact', contact_email: '')
+
+ expect(response).to have_http_status(:unprocessable_content)
+ expect(user.reload.email_visibility).to eq('login')
+ end
+
+ it 'refuses an unknown choice' do
+ save(email_visibility: 'public')
+
+ expect(response).to have_http_status(:unprocessable_content)
+ expect(user.reload.email_visibility).to eq('login')
+ end
+
+ it 'never changes the login address or the password on this path' do
+ save(email_visibility: 'none', email: '[email protected]', password: 'newpassword1', password_confirmation: 'newpassword1')
+
+ expect(user.reload.email).to eq('[email protected]')
+ expect(user.valid_password?('password123')).to be(true)
+ expect(user.email_visibility).to eq('none')
+ end
+
+ it 'leaves the choice alone when the section is saved without it' do
+ user.update!(email_visibility: 'none')
+
+ patch user_preferences_path, params: { current_section: 'display', preferences: { name_display: 'full' } }
+
+ expect(user.reload.email_visibility).to eq('none')
+ end
+end
diff --git a/spec/system/email_visibility_spec.rb b/spec/system/email_visibility_spec.rb
new file mode 100644
index 0000000..85c95e5
--- /dev/null
+++ b/spec/system/email_visibility_spec.rb
@@ -0,0 +1,69 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+# With real clicks: a member chooses in the display settings which email the
+# others see, and another member then sees exactly that on the members page and
+# in the people directory (User::EmailDisplay).
+RSpec.describe 'Choosing the email the others see', type: :system do
+ let(:organisation) { create(:organisation) }
+ let(:role) { create(:role, organisation: organisation, title: Role::ACCOUNT_ADMIN_TITLE) }
+ let(:lena) { create(:user, first_name: 'Lena', last_name: 'Beispiel', email: '[email protected]') }
+ let(:adele) { create(:user, first_name: 'Adele', last_name: 'Beispiel', email: '[email protected]') }
+
+ before do
+ Prosopite.pause
+ ActsAsTenant.current_tenant = organisation
+ [lena, adele].each { |user| create(:membership, user: user, organisation: organisation, role: role, active: true) }
+ end
+
+ after do
+ ActsAsTenant.current_tenant = nil
+ Prosopite.resume
+ end
+
+ def screenshot(name)
+ page.execute_script('document.getAnimations().forEach((animation) => animation.finish())')
+ directory = Rails.root.join('tmp/screenshots')
+ FileUtils.mkdir_p(directory)
+ page.driver.browser.save_screenshot(directory.join("#{name}.png").to_s)
+ end
+
+ def choose_and_save(choice, address: nil)
+ visit display_user_preferences_path
+ choose I18n.t("user_preferences.edit.display.email_visibility.#{choice}", email: lena.email)
+ fill_in I18n.t('user_preferences.edit.display.email_visibility.contact_label'), with: address if address
+ click_button I18n.t('user_preferences.edit.actions.save')
+ expect(page).to have_text(I18n.t('user_preferences.settings_updated'))
+ end
+
+ it 'shows the contact address to another member, and nothing after choosing none' do
+ sign_in lena
+ choose_and_save('contact', address: '[email protected]')
+ screenshot('email_visibility_settings')
+ expect(lena.reload).to have_attributes(email_visibility: 'contact', contact_email: '[email protected]')
+
+ sign_out lena
+ sign_in adele
+ visit organisation_memberships_path(organisation)
+ expect(page).to have_text('Lena')
+ expect(page).to have_text('[email protected]')
+ expect(page).to have_no_text('[email protected]')
+ screenshot('email_visibility_members_page')
+
+ visit organisation_people_path(organisation)
+ expect(page).to have_text('[email protected]')
+ expect(page).to have_no_text('[email protected]')
+
+ sign_out adele
+ sign_in lena
+ choose_and_save('none')
+
+ sign_out lena
+ sign_in adele
+ visit organisation_memberships_path(organisation)
+ expect(page).to have_text('Lena')
+ expect(page).to have_no_text('[email protected]')
+ expect(page).to have_no_text('[email protected]')
+ end
+end