diff --git a/admin/src/components/Layout.tsx b/admin/src/components/Layout.tsx
index 14bf448..4e5b433 100644
--- a/admin/src/components/Layout.tsx
+++ b/admin/src/components/Layout.tsx
@@ -24,6 +24,7 @@ import { Topbar } from '../topbar';
import { Brandmark } from './Brandmark';
import { Avatar } from './Avatar';
import { buildInfo } from '../lib/build-info';
+import { maskEmail } from '../lib/format';
import { cn } from '../lib/utils';
interface NavItem {
@@ -191,7 +192,9 @@ export default function Layout() {
const isTrainer = useIsTrainer();
const build = buildInfo();
const fullName =
- [user?.firstName, user?.lastName].filter(Boolean).join(' ') || user?.email || '?';
+ [user?.firstName, user?.lastName].filter(Boolean).join(' ') ||
+ user?.nickname ||
+ (user ? maskEmail(user.email) : '?');
const roles = [
user?.isAdmin ? t('nav.roleAdmin') : null,
isTrainer ? t('nav.roleTrainer') : t('nav.roleMember'),
@@ -210,7 +213,9 @@ export default function Layout() {
): string =>
String(i18n.t(`logs:${key}`, options as never));
@@ -27,7 +27,7 @@ export function formatLogDate(iso: string) {
export function actorName(log: ActivityLog) {
const { firstName, lastName, email } = log.actor;
- return [firstName, lastName].filter(Boolean).join(' ') || email;
+ return [firstName, lastName].filter(Boolean).join(' ') || maskEmail(email);
}
/** Nazwa obiektu z szczegółów wpisu (tytuł planu, nazwa siłowni, nazwa obwodu). */
@@ -111,7 +111,7 @@ export function LogTable({ logs }: { logs: ActivityLog[] }) {
{actorName(log)}
- {log.actor.email}
+ {maskEmail(log.actor.email)}
{log.actor.id}
diff --git a/admin/src/components/UserPicker.tsx b/admin/src/components/UserPicker.tsx
index 67a11a9..a3f3f08 100644
--- a/admin/src/components/UserPicker.tsx
+++ b/admin/src/components/UserPicker.tsx
@@ -2,9 +2,10 @@ import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Search, X } from 'lucide-react';
import type { User } from '../api/types';
+import { maskEmail } from '../lib/format';
export function userLabel(u: User): string {
- return [u.firstName, u.lastName].filter(Boolean).join(' ') || u.email;
+ return [u.firstName, u.lastName].filter(Boolean).join(' ') || maskEmail(u.email);
}
/** Przeszukiwalny wybór użytkownika (listę pobiera strona) — wzór: GymPicker z członkostw. */
@@ -102,7 +103,7 @@ export function UserPicker({
>
{userLabel(u)}
{u.firstName && (
- {u.email}
+ {maskEmail(u.email)}
)}
))
diff --git a/admin/src/lib/format.ts b/admin/src/lib/format.ts
index b6091bd..4913831 100644
--- a/admin/src/lib/format.ts
+++ b/admin/src/lib/format.ts
@@ -15,6 +15,27 @@ export function displayName(
return u.nickname || [u.firstName, u.lastName].filter(Boolean).join(' ') || fallback;
}
+/**
+ * Maska adresu e-mail do wyświetlania w panelu admina: pierwsza i ostatnia litera
+ * local part, pierwsza litera domeny i TLD — reszta jako gwiazdki (np. jan@fitos.pl → j*n@f****.pl).
+ */
+export function maskEmail(email: string | null | undefined): string {
+ if (!email) return '—';
+ const at = email.indexOf('@');
+ if (at < 1) return '*';
+ const local = email.slice(0, at);
+ const localMask =
+ local.length <= 2
+ ? `${local.slice(0, 1)}${'*'.repeat(Math.max(local.length - 1, 1))}`
+ : `${local.slice(0, 1)}${'*'.repeat(local.length - 2)}${local.slice(-1)}`;
+ const domain = email.slice(at + 1);
+ const dot = domain.indexOf('.');
+ const firstLabel = dot < 0 ? domain : domain.slice(0, dot);
+ const rest = dot < 0 ? '' : domain.slice(dot);
+ const domainMask = `${firstLabel.slice(0, 1)}${'*'.repeat(Math.max(firstLabel.length - 1, 1))}${rest}`;
+ return `${localMask}@${domainMask}`;
+}
+
export function fmtDate(iso: string | null | undefined): string {
if (!iso) return '—';
return new Date(iso).toLocaleDateString(currentTag(), {
diff --git a/admin/src/pages/Verifications.tsx b/admin/src/pages/Verifications.tsx
index f0651d6..815f9a4 100644
--- a/admin/src/pages/Verifications.tsx
+++ b/admin/src/pages/Verifications.tsx
@@ -24,7 +24,7 @@ import {
import type { BadgeColor } from '../components/ui';
import { Avatar } from '../components/Avatar';
import { formatAvailability } from '../lib/availability';
-import { fmtDate } from '../lib/format';
+import { fmtDate, maskEmail } from '../lib/format';
import i18n from '../i18n';
import { useTopbar } from '../topbar';
@@ -47,7 +47,7 @@ function claimTypeLabel(claim: GymClaim) {
function applicantName(claim: GymClaim) {
const { firstName, lastName, email } = claim.user;
- return [firstName, lastName].filter(Boolean).join(' ') || email;
+ return [firstName, lastName].filter(Boolean).join(' ') || maskEmail(email);
}
/** Pobranie pliku przez `apiBlob` (Bearer + rotacja 401) → tymczasowy . */
@@ -284,7 +284,7 @@ export function VerificationDetail() {
{claim.companyName || '—'}
{claim.nip || '—'}
{claim.phone || '—'}
- {claim.email || '—'}
+ {claim.email ? maskEmail(claim.email) : '—'}
@@ -297,7 +297,7 @@ export function VerificationDetail() {
{applicantName(claim)}
- {claim.user.email}
+ {maskEmail(claim.user.email)}
{claim.user.phone != null && (
{claim.user.phone}
)}
diff --git a/admin/src/pages/gyms/GymDetail.tsx b/admin/src/pages/gyms/GymDetail.tsx
index c56e180..854f559 100644
--- a/admin/src/pages/gyms/GymDetail.tsx
+++ b/admin/src/pages/gyms/GymDetail.tsx
@@ -32,7 +32,7 @@ import {
} from '../../components/ui';
import { AvailabilityEditor } from '../../components/AvailabilityEditor';
import { dayFull, formatDayRangeClock, normalizeAvailability } from '../../lib/availability';
-import { fmtDate, fmtDateTime } from '../../lib/format';
+import { fmtDate, fmtDateTime, maskEmail } from '../../lib/format';
import { GYM_ROLE_META, GYM_ROLE_ORDER } from '../../lib/roles';
import { useAdminUsers } from '../users/user-queries';
import { useGymAuditLogs, useGymMembers, useGymRelated } from '../../api/queries';
@@ -70,7 +70,16 @@ function HoursList({ gym }: { gym: Gym }) {
}
function memberLabel(m: AdminGymMemberItem): string {
- return [m.user.firstName, m.user.lastName].filter(Boolean).join(' ') || m.user.email;
+ return personName(m.user);
+}
+
+/* Nazwa osoby; fallback na zamaskowany e-mail. */
+function personName(p: {
+ firstName?: string | null;
+ lastName?: string | null;
+ email: string;
+}): string {
+ return [p.firstName, p.lastName].filter(Boolean).join(' ') || maskEmail(p.email);
}
/* Rola jako pigułki — te same etykiety co na członkostwach usera. */
@@ -122,7 +131,7 @@ function MembersTable({
>
|
{memberLabel(m)}
- {m.user.email}
+ {maskEmail(m.user.email)}
|
@@ -590,8 +599,7 @@ export default function GymDetail() {
to={`/users/${c.user.id}`}
className="font-semibold hover:text-accent-text"
>
- {[c.user.firstName, c.user.lastName].filter(Boolean).join(' ') ||
- c.user.email}
+ {personName(c.user)}
- {[inv.user.firstName, inv.user.lastName].filter(Boolean).join(' ') ||
- inv.user.email}
+ {personName(inv.user)}
- {t('invitedBy')}{' '}
- {[inv.invitedBy.firstName, inv.invitedBy.lastName]
- .filter(Boolean)
- .join(' ') || inv.invitedBy.email}
+ {t('invitedBy')} {personName(inv.invitedBy)}
- {user.email}
+ {maskEmail(user.email)}
{user.status === 'SUSPENDED' && (
diff --git a/admin/src/pages/users/UserForm.tsx b/admin/src/pages/users/UserForm.tsx
index e7a4182..d09e9e2 100644
--- a/admin/src/pages/users/UserForm.tsx
+++ b/admin/src/pages/users/UserForm.tsx
@@ -5,7 +5,7 @@ import { Building2, Check, ChevronDown, ShieldCheck, Trash2, UserPlus } from 'lu
import { api } from '../../api/client';
import type { Gym, GymRole, User } from '../../api/types';
import { ADMIN_ROLE_META, GYM_ROLE_META } from '../../lib/roles';
-import { todayStr } from '../../lib/format';
+import { todayStr, maskEmail } from '../../lib/format';
import { GymPicker } from '../../components/GymPicker';
import { GymRolePicker } from '../../components/GymRolePicker';
import {
@@ -222,7 +222,8 @@ export default function UserForm() {
return;
}
- // EDYCJA: PATCH konta (tożsamość/dostęp), potem porządkowanie członkostw
+ // EDYCJA: PATCH konta (tożsamość/dostęp), potem porządkowanie członkostw.
+ // E-mail w edycji jest ukryty (zna go tylko user) — PATCH przenosi niezmieniony adres.
const patchBody: Record = {
email: form.email.trim(),
firstName: form.firstName || null,
@@ -315,12 +316,18 @@ export default function UserForm() {
/>
- setForm({ ...form, email: e.target.value })}
- required
- />
+ {isEdit ? (
+ // w edycji e-mail jest zamaskowany i tylko do odczytu (zna go tylko user);
+ // PATCH poniżej przenosi niezmieniony, pełny adres z formularza
+
+ ) : (
+ setForm({ ...form, email: e.target.value })}
+ required
+ />
+ )}
- {u.email}
+ {maskEmail(u.email)}
{ageFromBirthDate(u.birthDate) != null
? ` · ${t('ageWord', { age: ageFromBirthDate(u.birthDate) })}`
: ''}
diff --git a/admin/test/GymDetail.test.tsx b/admin/test/GymDetail.test.tsx
index 34cfe4b..35d8f8b 100644
--- a/admin/test/GymDetail.test.tsx
+++ b/admin/test/GymDetail.test.tsx
@@ -268,6 +268,12 @@ describe('admin GymDetail (konsola)', () => {
expect(within(table).getByText('Anna Kowalska')).toBeInTheDocument();
const trainerRow = within(table).getByText('Jan Nowak').closest('tr');
expect(within(trainerRow as HTMLElement).getByText('Trener')).toBeInTheDocument();
+ // członkowie: e-maile zamaskowane; pełne adresy nigdy w DOM
+ expect(within(table).getByText('j*n@f****.pl')).toBeInTheDocument();
+ expect(within(table).getByText('a**a@f****.pl')).toBeInTheDocument();
+ expect(screen.queryByText('jan@fitos.pl')).not.toBeInTheDocument();
+ expect(screen.queryByText('anna@fitos.pl')).not.toBeInTheDocument();
+ expect(screen.queryByText('ola@fitos.pl')).not.toBeInTheDocument();
// brak przycisków w tabeli — akcje członka dopiero w menu z kliknięcia wiersza
expect(within(table).queryAllByRole('button')).toHaveLength(0);
diff --git a/admin/test/Logs.test.tsx b/admin/test/Logs.test.tsx
index 749dcd5..5a47a4a 100644
--- a/admin/test/Logs.test.tsx
+++ b/admin/test/Logs.test.tsx
@@ -93,10 +93,13 @@ describe('admin Logs page', () => {
expect(await screen.findByText('20.08.2026')).toBeInTheDocument();
// szczegóły jako naturalny tekst (tytuł i actorId są w innych kolumnach)
expect(await screen.findByText('start: 2026-08-24')).toBeInTheDocument();
- // ID aktora pod e-mailem w kolumnie „Użytkownik"
+ // ID aktora w kolumnie „Użytkownik"
expect(screen.getAllByText('user-1').length).toBeGreaterThan(0);
- // aktor: e-mail pod imieniem i nazwiskiem
- expect(screen.getByText('anna@test.local')).toBeInTheDocument();
+ // aktor: zamaskowany e-mail pod imieniem i nazwiskiem; pełny adres nigdy w DOM
+ expect(screen.getByText('a**a@t***.local')).toBeInTheDocument();
+ expect(screen.getAllByText('j*n@t***.local').length).toBeGreaterThan(0);
+ expect(screen.queryByText('anna@test.local')).not.toBeInTheDocument();
+ expect(screen.queryByText('jan@test.local')).not.toBeInTheDocument();
// etykiety akcji
expect(screen.getAllByText('Plan aktywowany').length).toBeGreaterThan(0);
expect(screen.getAllByText('Sesja zakończona').length).toBeGreaterThan(0);
@@ -161,7 +164,8 @@ describe('admin Logs page', () => {
// wyszukiwarka jest w menu kontekstowym (Layout) — filtr ustawiamy przez store
act(() => useListSearch.getState().setQuery('logs', 'anna'));
expect(screen.queryByText('Jan Kowalski')).not.toBeInTheDocument();
- expect(screen.getByText('anna@test.local')).toBeInTheDocument();
+ // LOG2: aktor Anna bez nazwiska — widoczna sama pierwsza imienna część
+ expect(screen.getByText('Anna')).toBeInTheDocument();
});
it('shows an error when the logs request fails', async () => {
diff --git a/admin/test/UserDetail.test.tsx b/admin/test/UserDetail.test.tsx
index 2566972..04789ae 100644
--- a/admin/test/UserDetail.test.tsx
+++ b/admin/test/UserDetail.test.tsx
@@ -135,8 +135,9 @@ describe('admin UserDetail (konsola użytkownika)', () => {
expect(await screen.findByRole('heading', { level: 2, name: 'jano' })).toBeInTheDocument();
expect(screen.getByRole('link', { name: 'Wróć' })).toHaveAttribute('href', '/users');
- // panel podsumowania: e-mail + nick + badge admina + pasek danych administracyjnych
- expect(screen.getByText('jan@test.local')).toBeInTheDocument();
+ // panel podsumowania: zamaskowany e-mail + nick + badge admina + pasek danych administracyjnych
+ expect(screen.getByText('j*n@t***.local')).toBeInTheDocument();
+ expect(screen.queryByText('jan@test.local')).not.toBeInTheDocument();
expect(screen.getByText('@jano')).toBeInTheDocument();
expect(screen.getByText('Admin')).toBeInTheDocument();
expect(screen.getByText('Ostatnie logowanie')).toBeInTheDocument();
diff --git a/admin/test/UserForm.test.tsx b/admin/test/UserForm.test.tsx
index c2bb0cb..bd53fa2 100644
--- a/admin/test/UserForm.test.tsx
+++ b/admin/test/UserForm.test.tsx
@@ -279,10 +279,14 @@ describe('admin UserForm — kreator edycji', () => {
{ match: '/admin/gyms', reply: () => ({ gyms: [GYM_A, GYM_B] }) },
{ match: '/admin/users', reply: () => ({ users: [EDITED] }) },
]);
- renderForm('/users/u1/edit');
+ const { container } = renderForm('/users/u1/edit');
// dane i członkostwo wczytane z użytkownika — krok 3 jest też w edycji
- expect(await screen.findByDisplayValue('jan@test.local')).toBeInTheDocument();
- expect(screen.getByDisplayValue('Jan')).toBeInTheDocument();
+ expect(await screen.findByDisplayValue('Jan')).toBeInTheDocument();
+ // w edycji e-mail zamaskowany i tylko do odczytu (pełny adres zna tylko user)
+ const emailInput = container.querySelector('input[type="email"]');
+ expect(emailInput).toBeNull();
+ const masked = container.querySelector('input[readonly]') as HTMLInputElement | null;
+ expect(masked?.value).toBe('j*n@t***.local');
expect(screen.getByDisplayValue('1996-05-05')).toBeInTheDocument();
expect(await screen.findByText('Członkostwa w siłowniach')).toBeInTheDocument();
expect(screen.getByDisplayValue('Fit Factory')).toBeInTheDocument();
@@ -296,7 +300,7 @@ describe('admin UserForm — kreator edycji', () => {
]);
const user = userEvent.setup();
renderForm('/users/u1/edit');
- await screen.findByDisplayValue('jan@test.local');
+ await screen.findByDisplayValue('Jan');
// edycja = tożsamość/dostęp: zmiana nazwiska; skłon ról bez zmian = zero żądań członkostw
const inputs = document.querySelectorAll('input');
@@ -308,8 +312,10 @@ describe('admin UserForm — kreator edycji', () => {
const accountPatch = calls.find(
(c) => c.init?.method === 'PATCH' && c.url === `${API_BASE}/admin/users/u1`,
);
+ // e-mail niewidoczny w formularzu, ale PATCH przenosi go bez zmian
expect(JSON.parse(accountPatch?.init?.body as string)).toMatchObject({
lastName: 'Nowak',
+ email: 'jan@test.local',
isAdmin: true,
});
expect(calls.some((c) => c.url.includes('/memberships'))).toBe(false);
diff --git a/admin/test/UsersList.test.tsx b/admin/test/UsersList.test.tsx
index 72f816a..421881b 100644
--- a/admin/test/UsersList.test.tsx
+++ b/admin/test/UsersList.test.tsx
@@ -96,8 +96,11 @@ describe('admin UsersList page', () => {
it('lists users fetched from the API', async () => {
mockFetchSequence(jsonResponse(200, { users: [U1, U2] }));
renderUsers();
- expect(await screen.findByText('jan@test.local · wiek: 30')).toBeInTheDocument();
- expect(screen.getByText('admin@test.local')).toBeInTheDocument();
+ // meta z zamaskowanym e-mailem; pełny adres nigdy nie trafia do DOM
+ expect(await screen.findByText('j*n@t***.local · wiek: 30')).toBeInTheDocument();
+ expect(screen.getByText('a***n@t***.local')).toBeInTheDocument();
+ expect(screen.queryByText('jan@test.local')).not.toBeInTheDocument();
+ expect(screen.queryByText('admin@test.local')).not.toBeInTheDocument();
// 'Admin' appears both as the user name link and as the admin badge
expect(screen.getAllByText('Admin')).toHaveLength(2);
});
@@ -105,11 +108,12 @@ describe('admin UsersList page', () => {
it('filters users by the search box', async () => {
mockFetchSequence(jsonResponse(200, { users: [U1, U2] }));
renderUsers();
- await screen.findByText('jan@test.local · wiek: 30');
+ await screen.findByText('j*n@t***.local · wiek: 30');
// wyszukiwarka jest w menu kontekstowym (Layout) — filtr ustawiamy przez store
act(() => useListSearch.getState().setQuery('users', 'admin'));
- expect(screen.queryByText('jan@test.local · wiek: 30')).not.toBeInTheDocument();
- expect(screen.getByText('admin@test.local')).toBeInTheDocument();
+ expect(screen.queryByText('j*n@t***.local · wiek: 30')).not.toBeInTheDocument();
+ // wyszukiwarka dopasowuje po pełnym e-mailu (serwerowo po q), lecz UI pokazuje maskę
+ expect(screen.getByText('a***n@t***.local')).toBeInTheDocument();
});
it('shows an error when the users request fails', async () => {
diff --git a/admin/test/e2e/admin.spec.ts b/admin/test/e2e/admin.spec.ts
index 7c4614d..44be0cf 100644
--- a/admin/test/e2e/admin.spec.ts
+++ b/admin/test/e2e/admin.spec.ts
@@ -160,8 +160,9 @@ test('kliknięcie w użytkownika otwiera konsolę administracyjną', async ({ pa
// topbar = kategoria „Użytkownik”, nazwa dopiero w treści (h2) + „← Wróć”
await expect(page.getByRole('heading', { level: 1, name: 'Użytkownik' })).toBeVisible();
await expect(page.getByRole('heading', { level: 2, name: 'Jan Kowalski' })).toBeVisible();
- // panel podsumowania: e-mail + pasek danych administracyjnych
- await expect(page.getByText('jan@fitos.pl')).toBeVisible();
+ // panel podsumowania: zamaskowany e-mail + pasek danych administracyjnych (pełny adres zna tylko user)
+ await expect(page.getByText('j*n@f****.pl')).toBeVisible();
+ await expect(page.getByText('jan@fitos.pl')).toHaveCount(0);
await expect(page.getByText('Ostatnie logowanie')).toBeVisible();
await expect(page.getByText('Członkostwa', { exact: true })).toBeVisible();
await expect(page.getByText('Konto od')).toBeVisible();
@@ -425,7 +426,9 @@ test('kreator edycji: zapis bez zmian członkostw wysyła tylko PATCH konta', as
await page.getByRole('button', { name: 'Edytuj' }).click();
await expect(page).toHaveURL(/\/users\/user-1\/edit$/);
await expect(page.getByRole('heading', { name: 'Edycja użytkownika' })).toBeVisible();
- await expect(page.locator('input[type="email"]')).toHaveValue('jan@fitos.pl');
+ // e-mail w edycji zamaskowany i tylko do odczytu (pełny adres zna tylko user)
+ await expect(page.locator('input[readonly]')).toHaveValue('j*n@f****.pl');
+ await expect(page.locator('input[type="email"]')).toHaveCount(0);
// pełny edytor: krok członkostw wczytany (skłon ról bez zmian = zero żądań członkostw)
await expect(page.getByRole('heading', { name: 'Członkostwa w siłowniach' })).toBeVisible();
await expect(page.getByRole('combobox', { name: 'Szukaj siłowni' })).toHaveValue('Fit Factory');
diff --git a/admin/test/e2e/verifications.spec.ts b/admin/test/e2e/verifications.spec.ts
index 20a727b..9f1f62c 100644
--- a/admin/test/e2e/verifications.spec.ts
+++ b/admin/test/e2e/verifications.spec.ts
@@ -38,9 +38,10 @@ test('szczegóły wniosku o nową realną: dane siłowni + wnioskodawca', async
// dane siłowni (typ nowa realna)
await expect(page.getByText('ul. Długa 5, Warszawa')).toBeVisible();
- // wnioskodawca
+ // wnioskodawca — e-mail zamaskowany (pełny adres zna tylko user)
await expect(page.getByText('Anna Nowa')).toBeVisible();
- await expect(page.getByText('nowa@fitos.pl').first()).toBeVisible();
+ await expect(page.getByText('n**a@f****.pl').first()).toBeVisible();
+ await expect(page.getByText('nowa@fitos.pl')).toHaveCount(0);
});
test('szczegóły wniosku o weryfikację: siłownia + dokument do pobrania', async ({ page }) => {
|