fix: preserve week-long sessions and add profile mascot
Co-authored-by: Stephan Charles <[email protected]> Co-authored-by: Amelia Hernandez <[email protected]> Co-authored-by: Markus Franz <[email protected]> Co-authored-by: Sabrina Hota <[email protected]> Co-authored-by: Nilüfer Doğan <[email protected]>
No files matched your search
|
After Width: | Height: | Size: 1.6 MiB |
|
After Width: | Height: | Size: 1.4 MiB |
|
After Width: | Height: | Size: 1.7 MiB |
|
After Width: | Height: | Size: 1.6 MiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 16 KiB |
@@ -119,8 +119,8 @@ export function Login() {
|
|||||||
<Scanner
|
<Scanner
|
||||||
onResult={handleScan}
|
onResult={handleScan}
|
||||||
label="Point your camera at your lanyard QR"
|
label="Point your camera at your lanyard QR"
|
||||||
entryLabel="QR code or admin email"
|
entryLabel="QR Code"
|
||||||
placeholder="QR code or admin email"
|
placeholder="QR Code"
|
||||||
disabled={busy}
|
disabled={busy}
|
||||||
submitDisabled={isEmailEntry(entry) && cooldown > 0}
|
submitDisabled={isEmailEntry(entry) && cooldown > 0}
|
||||||
submitLabel={busy ? 'Sending...' : isEmailEntry(entry) ? cooldown ? `Resend in ${cooldown}s` : sent ? 'Resend magic link' : 'Send magic link' : 'Go'}
|
submitLabel={busy ? 'Sending...' : isEmailEntry(entry) ? cooldown ? `Resend in ${cooldown}s` : sent ? 'Resend magic link' : 'Send magic link' : 'Go'}
|
||||||
|
|||||||
@@ -14,9 +14,12 @@ const CATEGORY_LABEL: Record<PointsLogRow['category'], string> = {
|
|||||||
admin: 'Other',
|
admin: 'Other',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const MANFRED_POSES = ['confident', 'coffee', 'celebrating', 'waving'];
|
||||||
|
|
||||||
export function Profile() {
|
export function Profile() {
|
||||||
const { contact, registration, signOut, refresh } = useAuth();
|
const { contact, registration, signOut, refresh } = useAuth();
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
|
const [manfredPose] = useState(() => MANFRED_POSES[Math.floor(Math.random() * MANFRED_POSES.length)]);
|
||||||
const [log, setLog] = useState<PointsLogRow[]>([]);
|
const [log, setLog] = useState<PointsLogRow[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
@@ -70,7 +73,18 @@ export function Profile() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="screen">
|
<section className="screen">
|
||||||
<div className="h1">Profile</div>
|
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 16 }}>
|
||||||
|
<div className="h1" style={{ marginBottom: 0 }}>Profile</div>
|
||||||
|
<img
|
||||||
|
src={`/manfred/${manfredPose}.webp`}
|
||||||
|
alt="Manfred"
|
||||||
|
title="Manfred"
|
||||||
|
data-testid="profile-manfred"
|
||||||
|
width={76}
|
||||||
|
height={76}
|
||||||
|
style={{ objectFit: 'contain', flexShrink: 0 }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div className="card" style={{ textAlign: 'center' }}>
|
<div className="card" style={{ textAlign: 'center' }}>
|
||||||
<Avatar name={contact.full_name} id={contact.email} size={72} fs={26} />
|
<Avatar name={contact.full_name} id={contact.email} size={72} fs={26} />
|
||||||
<div className="h2" style={{ marginTop: 10 }}>{contact.full_name}</div>
|
<div className="h2" style={{ marginTop: 10 }}>{contact.full_name}</div>
|
||||||
|
|||||||
@@ -1,3 +1,28 @@
|
|||||||
|
# Session Persistence
|
||||||
|
|
||||||
|
Logged-in sessions have a seven-day maximum lifetime and seven-day inactivity
|
||||||
|
timeout (`[auth.sessions]` timebox/inactivity_timeout `168h`). The browser keeps
|
||||||
|
its Supabase session in persistent storage and refreshes tokens automatically;
|
||||||
|
users do not need to sign in when an access token expires. Multiple devices are
|
||||||
|
allowed. Logout, changed passwords, revoked sessions or cleared browser storage
|
||||||
|
still require authentication. Limits take effect when refresh is attempted, not
|
||||||
|
by invalidating an already-issued JWT immediately.
|
||||||
|
|
||||||
|
On production, set `GOTRUE_SESSIONS_TIMEBOX=168h`,
|
||||||
|
`GOTRUE_SESSIONS_INACTIVITY_TIMEOUT=168h` and
|
||||||
|
`GOTRUE_SESSIONS_SINGLE_PER_USER=false` on the existing Auth container. Preserve
|
||||||
|
the other runtime settings, signing keys, SMTP and image. The deployed JWT expiry
|
||||||
|
remains 86400 seconds; session lifetime and JWT lifetime are separate settings.
|
||||||
|
The repository's local JWT expiry remains its existing configured value.
|
||||||
|
|
||||||
|
Migration `20261010183614_preserve_sessions_on_unchanged_ticket` prevents the
|
||||||
|
Pretix `_ensure_auth_user` helper from revoking sessions during unchanged imports.
|
||||||
|
It locks the user and checks the existing password hash before updating it.
|
||||||
|
Actual password changes continue to revoke sessions. Existing sessions that were
|
||||||
|
already deleted cannot be restored; those users need to sign in once.
|
||||||
|
|
||||||
|
See [release record](../releases/2026-10-10.md#follow-up-deployments) for the
|
||||||
|
production backup, verification and deployment boundaries.
|
||||||
# Supabase Core — Local Stack
|
# Supabase Core — Local Stack
|
||||||
|
|
||||||
The Supabase core is a set of Docker containers managed by the **Supabase CLI**
|
The Supabase core is a set of Docker containers managed by the **Supabase CLI**
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
# Session Persistence Regression
|
||||||
|
|
||||||
|
Run the rollback-only fixture after applying
|
||||||
|
`20261010183614_preserve_sessions_on_unchanged_ticket`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
|
||||||
|
-v ON_ERROR_STOP=1 < supabase/tests/session_persistence_tests.sql
|
||||||
|
```
|
||||||
|
|
||||||
|
It verifies unchanged repeated imports preserve the existing password hash and
|
||||||
|
session, changed ticket passwords revoke sessions, and admin password precedence
|
||||||
|
survives ticket changes. No fixture accounts remain after rollback.
|
||||||
|
|
||||||
|
The production Auth policy was additionally verified with a disposable confirmed
|
||||||
|
test account: actual refresh succeeded at six days, failed after the seven-day
|
||||||
|
lifetime, and failed after eight-day inactivity. Cleanup removed the test account;
|
||||||
|
no real email was sent. See [release record](../releases/2026-10-10.md#follow-up-deployments).
|
||||||
# Backend — RPC Test Suite
|
# Backend — RPC Test Suite
|
||||||
|
|
||||||
A self-contained, idempotent test suite for the transactional points RPCs, role
|
A self-contained, idempotent test suite for the transactional points RPCs, role
|
||||||
|
|||||||
@@ -293,6 +293,10 @@ event). The `leaderboard` table is kept in sync transactionally by the RPCs —
|
|||||||
|
|
||||||
## Profile
|
## Profile
|
||||||
|
|
||||||
|
- **Manfred** — a compact mascot beside the title uses one of four transparent
|
||||||
|
WebP poses from `apps/convivo/public/manfred`. A pose is selected randomly each
|
||||||
|
time Profile mounts, including returning from another tab or refreshing; it
|
||||||
|
stays stable during edits. Random selection can repeat the previous pose.
|
||||||
- **Header** — avatar, name, email, registration-type pill, a **staff** pill
|
- **Header** — avatar, name, email, registration-type pill, a **staff** pill
|
||||||
(only when `contact.is_admin` **and** the type isn't already `staff`, so it
|
(only when `contact.is_admin` **and** the type isn't already `staff`, so it
|
||||||
never shows twice), and a points pill.
|
never shows twice), and a points pill.
|
||||||
|
|||||||
@@ -90,6 +90,51 @@ blindly or remove a merge mapping after users have merged real tickets.
|
|||||||
deployment. Shared authenticated-browser inspection was unavailable; API-mocked
|
deployment. Shared authenticated-browser inspection was unavailable; API-mocked
|
||||||
browser tests and direct production checks were used instead.
|
browser tests and direct production checks were used instead.
|
||||||
|
|
||||||
|
## Follow-up Deployments
|
||||||
|
|
||||||
|
- QR-only login hint: `entryLabel` and `placeholder` now say `QR Code`, with
|
||||||
|
existing admin-email magic-link behavior unchanged. Attendee-only deployment
|
||||||
|
backup: `qr-hint-20261010T113838Z`; 31 API-mocked production tests passed.
|
||||||
|
- Profile Manfred easter egg: four transparent 224px WebP poses appear beside
|
||||||
|
the Profile title at 76px. Random choice occurs on each mount, including tab
|
||||||
|
re-entry and refresh, and remains stable during edits. Choices may repeat.
|
||||||
|
Original artwork is retained in `Manfred/`; optimized assets live in
|
||||||
|
`apps/convivo/public/manfred/`. Backup: `manfred-20261010T114633Z`.
|
||||||
|
All 33 login/profile production-bundle tests passed, including 360px/1280px
|
||||||
|
image loading, layout and lifecycle checks. Only the attendee app restarted.
|
||||||
|
- Public asset deployment requires directory mode `755` and file mode `644`.
|
||||||
|
Restrictive transfer permissions initially caused 403s; source permissions
|
||||||
|
were corrected and the image rebuilt. Nginx Proxy Manager cached those errors
|
||||||
|
for 30 minutes. Only cache entries matching the four new image URLs were
|
||||||
|
invalidated, checking both the MD5 filename and embedded cache key. The proxy
|
||||||
|
was not restarted and unrelated cache entries were not removed.
|
||||||
|
- Seven-day sessions: migration
|
||||||
|
`20261010183614_preserve_sessions_on_unchanged_ticket` is installed with a
|
||||||
|
migration-ledger entry. Pretix's password helper previously rehashed unchanged
|
||||||
|
passwords and deleted sessions every sync. It now locks the user, compares the
|
||||||
|
supplied password against the existing hash, and only rewrites the password
|
||||||
|
and revokes sessions when the effective password actually changes.
|
||||||
|
- Auth now uses `GOTRUE_SESSIONS_TIMEBOX=168h`,
|
||||||
|
`GOTRUE_SESSIONS_INACTIVITY_TIMEOUT=168h`, and
|
||||||
|
`GOTRUE_SESSIONS_SINGLE_PER_USER=false`. Persistent session config is aligned.
|
||||||
|
This is a refreshable session lifetime, not a week-long JWT. Existing
|
||||||
|
production JWT expiry (`86400` seconds), issuer/signing keys, SMTP, redirects,
|
||||||
|
image and container settings were preserved. Only Auth restarted; other
|
||||||
|
container IDs/start times were unchanged. Backup:
|
||||||
|
`week-sessions-20261010T183742Z`, including the database, previous config and
|
||||||
|
private Auth inspect, plus the retained rollback Auth container.
|
||||||
|
- Three rollback-only password-sync checks passed locally and in production.
|
||||||
|
Actual Auth refresh requests using a disposable confirmed test account accepted
|
||||||
|
a six-day-old inactive session and rejected both an expired seven-day lifetime
|
||||||
|
and eight-day inactivity. The account was deleted in cleanup; no real email
|
||||||
|
was sent. Existing users may need to sign in once if an earlier sync already
|
||||||
|
revoked their session. Clearing browser storage, explicit logout, password
|
||||||
|
changes or other security revocations still require sign-in. Limits are checked
|
||||||
|
on refresh, so an already-issued JWT can remain valid until its own expiry.
|
||||||
|
- Final combined validation passed: both frontend builds, nine importer tests,
|
||||||
|
browser-test TypeScript and all 37 API-mocked production-bundle login, profile
|
||||||
|
and ticket-merge checks.
|
||||||
|
|
||||||
## Credential Handling
|
## Credential Handling
|
||||||
|
|
||||||
The private SMTP instructions are ignored by Git. Earlier diagnostic output
|
The private SMTP instructions are ignored by Git. Earlier diagnostic output
|
||||||
|
|||||||
@@ -4,6 +4,46 @@ const appUrl = process.env.CONVIVO_BASE_URL || 'http://localhost:3000';
|
|||||||
const notice = 'If this email belongs to an eligible admin account, a sign-in link has been sent.';
|
const notice = 'If this email belongs to an eligible admin account, a sign-in link has been sent.';
|
||||||
const invalidLink = 'This sign-in link is invalid or expired. Please request a new link.';
|
const invalidLink = 'This sign-in link is invalid or expired. Please request a new link.';
|
||||||
|
|
||||||
|
test.describe('Profile Manfred', () => {
|
||||||
|
for (const viewport of [{ width: 360, height: 800 }, { width: 1280, height: 900 }]) {
|
||||||
|
test(`randomizes on entry and refresh without shifting the layout at ${viewport.width}px`, async ({ page }, testInfo) => {
|
||||||
|
await page.setViewportSize(viewport);
|
||||||
|
await page.addInitScript(() => {
|
||||||
|
Math.random = () => Number(sessionStorage.getItem('test-manfred-choice') || '0.01');
|
||||||
|
});
|
||||||
|
const { session } = await mockApi(page, { registered: true, checkedIn: true });
|
||||||
|
await page.goto(`${appUrl}/auth/callback#access_token=${session.access_token}&refresh_token=${session.refresh_token}&type=magiclink`);
|
||||||
|
await expect(page.getByTestId('tab-home')).toBeVisible();
|
||||||
|
const mascot = page.getByTestId('profile-manfred');
|
||||||
|
const poses = ['confident', 'coffee', 'celebrating', 'waving'];
|
||||||
|
for (const [index, pose] of poses.entries()) {
|
||||||
|
await page.evaluate((choice) => sessionStorage.setItem('test-manfred-choice', String(choice)), (index + 0.1) / 4);
|
||||||
|
await page.getByTestId('tab-profile').click();
|
||||||
|
await expect(mascot).toHaveAttribute('src', `/manfred/${pose}.webp`);
|
||||||
|
await expect.poll(() => mascot.evaluate((image: HTMLImageElement) => image.complete && image.naturalWidth > 0)).toBe(true);
|
||||||
|
await page.getByTestId('profile-linkedin-url').fill(`https://linkedin.com/in/test-${index}`);
|
||||||
|
await expect(mascot).toHaveAttribute('src', `/manfred/${pose}.webp`);
|
||||||
|
await page.locator('.screen').evaluate((screen) => { screen.scrollTop = 0; });
|
||||||
|
const bounds = await mascot.boundingBox();
|
||||||
|
expect(bounds).not.toBeNull();
|
||||||
|
expect(bounds!.y).toBeGreaterThanOrEqual(0);
|
||||||
|
expect(bounds!.width).toBe(76);
|
||||||
|
expect(bounds!.height).toBe(76);
|
||||||
|
expect(bounds!.x + bounds!.width).toBeLessThanOrEqual(viewport.width);
|
||||||
|
const heading = await page.locator('.screen > div .h1').boundingBox();
|
||||||
|
expect(heading!.x + heading!.width).toBeLessThan(bounds!.x);
|
||||||
|
if (index === poses.length - 1) await page.screenshot({ path: testInfo.outputPath(`profile-manfred-${viewport.width}.png`), fullPage: true });
|
||||||
|
await page.getByTestId('tab-home').click();
|
||||||
|
await expect(mascot).toHaveCount(0);
|
||||||
|
}
|
||||||
|
await page.evaluate(() => sessionStorage.setItem('test-manfred-choice', '0.01'));
|
||||||
|
await page.reload();
|
||||||
|
await page.getByTestId('tab-profile').click();
|
||||||
|
await expect(mascot).toHaveAttribute('src', '/manfred/confident.webp');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function mockSession(email: string) {
|
function mockSession(email: string) {
|
||||||
const user = {
|
const user = {
|
||||||
id: '11111111-1111-4111-8111-111111111111', aud: 'authenticated', role: 'authenticated', email,
|
id: '11111111-1111-4111-8111-111111111111', aud: 'authenticated', role: 'authenticated', email,
|
||||||
@@ -68,7 +108,8 @@ async function mockApi(page: Page, options: { email?: string; admin?: boolean; r
|
|||||||
async function openEntry(page: Page) {
|
async function openEntry(page: Page) {
|
||||||
await page.goto(appUrl);
|
await page.goto(appUrl);
|
||||||
await page.getByTestId('login-splash').click();
|
await page.getByTestId('login-splash').click();
|
||||||
await expect(page.getByLabel('QR code or admin email')).toBeVisible();
|
await expect(page.getByLabel('QR Code')).toBeVisible();
|
||||||
|
await expect(page.getByLabel('QR Code')).toHaveAttribute('placeholder', 'QR Code');
|
||||||
}
|
}
|
||||||
|
|
||||||
test.describe('Convivo admin email entry', () => {
|
test.describe('Convivo admin email entry', () => {
|
||||||
@@ -76,8 +117,8 @@ test.describe('Convivo admin email entry', () => {
|
|||||||
test(`ineligible ${email} gets private confirmation without OTP`, async ({ page }) => {
|
test(`ineligible ${email} gets private confirmation without OTP`, async ({ page }) => {
|
||||||
const { calls } = await mockApi(page, { email, admin: false });
|
const { calls } = await mockApi(page, { email, admin: false });
|
||||||
await openEntry(page);
|
await openEntry(page);
|
||||||
await page.getByLabel('QR code or admin email').fill(email);
|
await page.getByLabel('QR Code').fill(email);
|
||||||
await page.getByLabel('QR code or admin email').press('Enter');
|
await page.getByLabel('QR Code').press('Enter');
|
||||||
await expect(page.getByRole('status')).toHaveText(notice);
|
await expect(page.getByRole('status')).toHaveText(notice);
|
||||||
expect(calls.otp).toBe(0);
|
expect(calls.otp).toBe(0);
|
||||||
expect(calls.lanyards).toBe(0);
|
expect(calls.lanyards).toBe(0);
|
||||||
@@ -89,7 +130,7 @@ test.describe('Convivo admin email entry', () => {
|
|||||||
const { calls } = await mockApi(page);
|
const { calls } = await mockApi(page);
|
||||||
await page.route('**/rest/v1/rpc/can_request_admin_magic_link', (route) => route.fulfill({ status: 401, json: { message: 'Sensitive eligibility detail' } }));
|
await page.route('**/rest/v1/rpc/can_request_admin_magic_link', (route) => route.fulfill({ status: 401, json: { message: 'Sensitive eligibility detail' } }));
|
||||||
await openEntry(page);
|
await openEntry(page);
|
||||||
await page.getByLabel('QR code or admin email').fill('[email protected]');
|
await page.getByLabel('QR Code').fill('[email protected]');
|
||||||
await page.getByTestId('scanner-manual-go').click();
|
await page.getByTestId('scanner-manual-go').click();
|
||||||
await expect(page.getByRole('alert')).toHaveText('Unable to send a sign-in link right now. Please try again later.');
|
await expect(page.getByRole('alert')).toHaveText('Unable to send a sign-in link right now. Please try again later.');
|
||||||
expect(calls.otp).toBe(0);
|
expect(calls.otp).toBe(0);
|
||||||
@@ -101,7 +142,7 @@ test.describe('Convivo admin email entry', () => {
|
|||||||
await mockApi(page);
|
await mockApi(page);
|
||||||
await page.route('**/auth/v1/otp**', (route) => route.fulfill({ status: responseStatus, json: { message: 'Sensitive account detail' } }));
|
await page.route('**/auth/v1/otp**', (route) => route.fulfill({ status: responseStatus, json: { message: 'Sensitive account detail' } }));
|
||||||
await openEntry(page);
|
await openEntry(page);
|
||||||
await page.getByLabel('QR code or admin email').fill('[email protected]');
|
await page.getByLabel('QR Code').fill('[email protected]');
|
||||||
await page.getByTestId('scanner-manual-go').click();
|
await page.getByTestId('scanner-manual-go').click();
|
||||||
if (responseStatus === 400 || responseStatus === 422) {
|
if (responseStatus === 400 || responseStatus === 422) {
|
||||||
await expect(page.getByRole('status')).toHaveText(notice);
|
await expect(page.getByRole('status')).toHaveText(notice);
|
||||||
@@ -110,7 +151,7 @@ test.describe('Convivo admin email entry', () => {
|
|||||||
await expect(page.getByTestId('scanner-manual-go')).toBeEnabled();
|
await expect(page.getByTestId('scanner-manual-go')).toBeEnabled();
|
||||||
}
|
}
|
||||||
await expect(page.getByText('Sensitive account detail')).toHaveCount(0);
|
await expect(page.getByText('Sensitive account detail')).toHaveCount(0);
|
||||||
await expect(page.getByLabel('QR code or admin email')).toBeEnabled();
|
await expect(page.getByLabel('QR Code')).toBeEnabled();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,7 +166,7 @@ test.describe('Convivo admin email entry', () => {
|
|||||||
await route.fulfill({ status: 202, json: { ok: true } });
|
await route.fulfill({ status: 202, json: { ok: true } });
|
||||||
});
|
});
|
||||||
await openEntry(page);
|
await openEntry(page);
|
||||||
const entry = page.getByLabel('QR code or admin email');
|
const entry = page.getByLabel('QR Code');
|
||||||
await expect(entry).toHaveAttribute('type', 'text');
|
await expect(entry).toHaveAttribute('type', 'text');
|
||||||
await entry.fill(' [email protected] ');
|
await entry.fill(' [email protected] ');
|
||||||
await expect(page.getByTestId('scanner-manual-go')).toHaveText('Send magic link');
|
await expect(page.getByTestId('scanner-manual-go')).toHaveText('Send magic link');
|
||||||
@@ -154,9 +195,9 @@ test.describe('Convivo admin email entry', () => {
|
|||||||
else await route.fulfill({ status: 503, json: { error: 'Sensitive server detail' } });
|
else await route.fulfill({ status: 503, json: { error: 'Sensitive server detail' } });
|
||||||
});
|
});
|
||||||
await openEntry(page);
|
await openEntry(page);
|
||||||
await page.getByLabel('QR code or admin email').fill('[email protected]');
|
await page.getByLabel('QR Code').fill('[email protected]');
|
||||||
await page.getByTestId('scanner-manual-go').click();
|
await page.getByTestId('scanner-manual-go').click();
|
||||||
await expect(page.getByLabel('QR code or admin email')).toBeDisabled();
|
await expect(page.getByLabel('QR Code')).toBeDisabled();
|
||||||
await expect(page.getByRole('button', { name: 'Sending...' })).toBeDisabled();
|
await expect(page.getByRole('button', { name: 'Sending...' })).toBeDisabled();
|
||||||
release();
|
release();
|
||||||
await expect(page.getByRole('status')).toHaveText(notice);
|
await expect(page.getByRole('status')).toHaveText(notice);
|
||||||
@@ -172,7 +213,7 @@ test.describe('Convivo admin email entry', () => {
|
|||||||
const { calls } = await mockApi(page);
|
const { calls } = await mockApi(page);
|
||||||
await page.route('**/auth/v1/otp**', (route) => route.abort());
|
await page.route('**/auth/v1/otp**', (route) => route.abort());
|
||||||
await openEntry(page);
|
await openEntry(page);
|
||||||
const entry = page.getByLabel('QR code or admin email');
|
const entry = page.getByLabel('QR Code');
|
||||||
await entry.fill('admin@');
|
await entry.fill('admin@');
|
||||||
await entry.press('Enter');
|
await entry.press('Enter');
|
||||||
await expect(page.getByRole('alert')).toHaveText('Enter a valid email address.');
|
await expect(page.getByRole('alert')).toHaveText('Enter a valid email address.');
|
||||||
@@ -251,7 +292,7 @@ test.describe('Convivo admin email entry', () => {
|
|||||||
await expect(page.getByRole('alert')).toHaveText(invalidLink);
|
await expect(page.getByRole('alert')).toHaveText(invalidLink);
|
||||||
await expect(page).toHaveURL(`${appUrl}/`);
|
await expect(page).toHaveURL(`${appUrl}/`);
|
||||||
expect(await page.evaluate(() => Object.keys(localStorage).filter((key) => key.endsWith('-auth-token')))).toEqual([]);
|
expect(await page.evaluate(() => Object.keys(localStorage).filter((key) => key.endsWith('-auth-token')))).toEqual([]);
|
||||||
await page.getByLabel('QR code or admin email').fill('[email protected]');
|
await page.getByLabel('QR Code').fill('[email protected]');
|
||||||
await page.getByRole('button', { name: 'Send magic link', exact: true }).click();
|
await page.getByRole('button', { name: 'Send magic link', exact: true }).click();
|
||||||
await expect(page.getByRole('status')).toHaveText(notice);
|
await expect(page.getByRole('status')).toHaveText(notice);
|
||||||
await expect(page.getByRole('alert')).toHaveCount(0);
|
await expect(page.getByRole('alert')).toHaveCount(0);
|
||||||
@@ -280,8 +321,8 @@ test.describe('Convivo admin email entry', () => {
|
|||||||
await route.fulfill({ json: mockSession('[email protected]') });
|
await route.fulfill({ json: mockSession('[email protected]') });
|
||||||
});
|
});
|
||||||
await openEntry(page);
|
await openEntry(page);
|
||||||
await page.getByLabel('QR code or admin email').fill('CVV-TEST-1234');
|
await page.getByLabel('QR Code').fill('CVV-TEST-1234');
|
||||||
await page.getByLabel('QR code or admin email').press('Enter');
|
await page.getByLabel('QR Code').press('Enter');
|
||||||
await expect(page.getByTestId('staff-login-password')).toBeVisible();
|
await expect(page.getByTestId('staff-login-password')).toBeVisible();
|
||||||
await expect(page.getByTestId('login-confirm')).toBeDisabled();
|
await expect(page.getByTestId('login-confirm')).toBeDisabled();
|
||||||
await page.getByTestId('staff-login-password').fill('mock-staff-password');
|
await page.getByTestId('staff-login-password').fill('mock-staff-password');
|
||||||
@@ -298,7 +339,7 @@ test.describe('Convivo admin email entry', () => {
|
|||||||
await mockApi(page, { admin: false, registered: true, checkedIn: true });
|
await mockApi(page, { admin: false, registered: true, checkedIn: true });
|
||||||
await page.route('**/auth/v1/token**', (route) => route.fulfill({ status: 400, json: { error: 'invalid_grant', error_description: 'Invalid login credentials' } }));
|
await page.route('**/auth/v1/token**', (route) => route.fulfill({ status: 400, json: { error: 'invalid_grant', error_description: 'Invalid login credentials' } }));
|
||||||
await openEntry(page);
|
await openEntry(page);
|
||||||
await page.getByLabel('QR code or admin email').fill('CVV-TEST-1234');
|
await page.getByLabel('QR Code').fill('CVV-TEST-1234');
|
||||||
await page.getByTestId('scanner-manual-go').click();
|
await page.getByTestId('scanner-manual-go').click();
|
||||||
await page.getByTestId('attendee-login-email').fill('[email protected]');
|
await page.getByTestId('attendee-login-email').fill('[email protected]');
|
||||||
await page.getByTestId('login-confirm').click();
|
await page.getByTestId('login-confirm').click();
|
||||||
@@ -310,17 +351,17 @@ test.describe('Convivo admin email entry', () => {
|
|||||||
await page.setViewportSize({ width: 375, height: 812 });
|
await page.setViewportSize({ width: 375, height: 812 });
|
||||||
const { calls } = await mockApi(page);
|
const { calls } = await mockApi(page);
|
||||||
await openEntry(page);
|
await openEntry(page);
|
||||||
await page.getByLabel('QR code or admin email').fill('[email protected]');
|
await page.getByLabel('QR Code').fill('[email protected]');
|
||||||
await page.getByRole('button', { name: 'Send magic link', exact: true }).click();
|
await page.getByRole('button', { name: 'Send magic link', exact: true }).click();
|
||||||
await expect(page.getByRole('status')).toHaveText(notice);
|
await expect(page.getByRole('status')).toHaveText(notice);
|
||||||
const button = await page.getByTestId('scanner-manual-go').boundingBox();
|
const button = await page.getByTestId('scanner-manual-go').boundingBox();
|
||||||
const input = await page.getByLabel('QR code or admin email').boundingBox();
|
const input = await page.getByLabel('QR Code').boundingBox();
|
||||||
expect(button).not.toBeNull();
|
expect(button).not.toBeNull();
|
||||||
expect(input).not.toBeNull();
|
expect(input).not.toBeNull();
|
||||||
expect(input!.x + input!.width).toBeLessThanOrEqual(button!.x);
|
expect(input!.x + input!.width).toBeLessThanOrEqual(button!.x);
|
||||||
expect(button!.x + button!.width).toBeLessThanOrEqual(375);
|
expect(button!.x + button!.width).toBeLessThanOrEqual(375);
|
||||||
await page.screenshot({ path: '/tmp/convivo-admin-entry-mobile.png', fullPage: true });
|
await page.screenshot({ path: '/tmp/convivo-admin-entry-mobile.png', fullPage: true });
|
||||||
await page.getByLabel('QR code or admin email').fill('CVV-TEST-1234');
|
await page.getByLabel('QR Code').fill('CVV-TEST-1234');
|
||||||
await expect(page.getByTestId('scanner-manual-go')).toHaveText('Go');
|
await expect(page.getByTestId('scanner-manual-go')).toHaveText('Go');
|
||||||
await expect(page.getByTestId('scanner-manual-go')).toBeEnabled();
|
await expect(page.getByTestId('scanner-manual-go')).toBeEnabled();
|
||||||
await page.getByTestId('scanner-manual-go').click();
|
await page.getByTestId('scanner-manual-go').click();
|
||||||
@@ -333,7 +374,7 @@ test.describe('Convivo admin email entry', () => {
|
|||||||
const { calls } = await mockApi(page);
|
const { calls } = await mockApi(page);
|
||||||
await page.goto(`${appUrl}/auth/callback${suffix}`);
|
await page.goto(`${appUrl}/auth/callback${suffix}`);
|
||||||
await expect(page.getByRole('alert')).toHaveText(invalidLink);
|
await expect(page.getByRole('alert')).toHaveText(invalidLink);
|
||||||
await expect(page.getByLabel('QR code or admin email')).toBeVisible();
|
await expect(page.getByLabel('QR Code')).toBeVisible();
|
||||||
await expect(page).toHaveURL(`${appUrl}/`);
|
await expect(page).toHaveURL(`${appUrl}/`);
|
||||||
expect(calls.exchanges).toBe(0);
|
expect(calls.exchanges).toBe(0);
|
||||||
expect(calls.users).toBe(0);
|
expect(calls.users).toBe(0);
|
||||||
@@ -346,7 +387,7 @@ test.describe('Convivo admin email entry', () => {
|
|||||||
const email = '[email protected]';
|
const email = '[email protected]';
|
||||||
const { calls } = await mockApi(page, { email, admin: false, registered: true, checkedIn });
|
const { calls } = await mockApi(page, { email, admin: false, registered: true, checkedIn });
|
||||||
await openEntry(page);
|
await openEntry(page);
|
||||||
await page.getByLabel('QR code or admin email').fill('CVV-TEST-1234');
|
await page.getByLabel('QR Code').fill('CVV-TEST-1234');
|
||||||
await page.getByTestId('scanner-manual-go').click();
|
await page.getByTestId('scanner-manual-go').click();
|
||||||
await page.getByTestId('attendee-login-email').fill(email);
|
await page.getByTestId('attendee-login-email').fill(email);
|
||||||
await page.getByTestId('login-confirm').click();
|
await page.getByTestId('login-confirm').click();
|
||||||
|
|||||||
@@ -279,11 +279,11 @@ max_frequency = "5s"
|
|||||||
# 4152127777 = "123456"
|
# 4152127777 = "123456"
|
||||||
|
|
||||||
# Configure logged in session timeouts.
|
# Configure logged in session timeouts.
|
||||||
# [auth.sessions]
|
[auth.sessions]
|
||||||
# Force log out after the specified duration.
|
# Force log out after the specified duration.
|
||||||
# timebox = "24h"
|
timebox = "168h"
|
||||||
# Force log out if the user has been inactive longer than the specified duration.
|
# Force log out if the user has been inactive longer than the specified duration.
|
||||||
# inactivity_timeout = "8h"
|
inactivity_timeout = "168h"
|
||||||
|
|
||||||
# This hook runs before a new user is created and allows developers to reject the request based on the incoming user object.
|
# This hook runs before a new user is created and allows developers to reject the request based on the incoming user object.
|
||||||
# [auth.hook.before_user_created]
|
# [auth.hook.before_user_created]
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
do $migration$
|
||||||
|
declare
|
||||||
|
definition text;
|
||||||
|
old_block text := E' else\n update auth.users\n set encrypted_password = extensions.crypt(v_pw, extensions.gen_salt(''bf'')),\n updated_at = now()\n where id = v_uid;\n delete from auth.sessions where user_id = v_uid;\n end if;';
|
||||||
|
new_block text := E' else\n perform 1 from auth.users where id = v_uid for update;\n if exists (\n select 1 from auth.users\n where id = v_uid\n and encrypted_password is distinct from extensions.crypt(v_pw, encrypted_password)\n ) then\n update auth.users\n set encrypted_password = extensions.crypt(v_pw, extensions.gen_salt(''bf'')),\n updated_at = now()\n where id = v_uid;\n delete from auth.sessions where user_id = v_uid;\n end if;\n end if;';
|
||||||
|
begin
|
||||||
|
select pg_get_functiondef('public._ensure_auth_user(text,text,text)'::regprocedure) into definition;
|
||||||
|
if strpos(definition, old_block) = 0 then
|
||||||
|
raise exception 'Unexpected _ensure_auth_user password update block';
|
||||||
|
end if;
|
||||||
|
execute replace(definition, old_block, new_block);
|
||||||
|
end;
|
||||||
|
$migration$;
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
begin;
|
||||||
|
|
||||||
|
do $test$
|
||||||
|
declare
|
||||||
|
fixture_email text := 'session-test-' || gen_random_uuid()::text || '@example.invalid';
|
||||||
|
fixture_uid uuid;
|
||||||
|
fixture_session uuid := gen_random_uuid();
|
||||||
|
previous_hash text;
|
||||||
|
previous_updated timestamptz;
|
||||||
|
begin
|
||||||
|
perform public._ensure_auth_user(fixture_email, 'Session Test', 'session-test-ticket');
|
||||||
|
select id, encrypted_password, updated_at into fixture_uid, previous_hash, previous_updated
|
||||||
|
from auth.users where email = fixture_email;
|
||||||
|
if fixture_uid is null then raise exception 'Fixture user was not created'; end if;
|
||||||
|
insert into auth.sessions (id, user_id, created_at, updated_at)
|
||||||
|
values (fixture_session, fixture_uid, now() - interval '6 days', now());
|
||||||
|
|
||||||
|
for iteration in 1..3 loop
|
||||||
|
perform public._ensure_auth_user(fixture_email, 'Session Test', 'session-test-ticket');
|
||||||
|
end loop;
|
||||||
|
if not exists (select 1 from auth.sessions where id = fixture_session) then
|
||||||
|
raise exception 'Unchanged imports revoked an existing session';
|
||||||
|
end if;
|
||||||
|
if not exists (select 1 from auth.users where id = fixture_uid
|
||||||
|
and encrypted_password = previous_hash and updated_at = previous_updated) then
|
||||||
|
raise exception 'Unchanged imports rewrote the password';
|
||||||
|
end if;
|
||||||
|
raise notice 'PASS: repeated unchanged ticket imports preserve session and password';
|
||||||
|
|
||||||
|
perform public._ensure_auth_user(fixture_email, 'Session Test', 'session-test-new-ticket');
|
||||||
|
if exists (select 1 from auth.sessions where id = fixture_session) then
|
||||||
|
raise exception 'Changed password did not revoke session';
|
||||||
|
end if;
|
||||||
|
if not exists (select 1 from auth.users where id = fixture_uid
|
||||||
|
and encrypted_password = extensions.crypt('session-test-new-ticket', encrypted_password)) then
|
||||||
|
raise exception 'Changed password was not synchronized';
|
||||||
|
end if;
|
||||||
|
raise notice 'PASS: changed ticket password updates hash and revokes session';
|
||||||
|
|
||||||
|
fixture_email := 'session-test-' || gen_random_uuid()::text || '@appe.at';
|
||||||
|
perform public._ensure_auth_user(fixture_email, 'Session Admin Test', 'first-ticket');
|
||||||
|
select id, encrypted_password into fixture_uid, previous_hash from auth.users where email = fixture_email;
|
||||||
|
fixture_session := gen_random_uuid();
|
||||||
|
insert into auth.sessions (id, user_id, created_at, updated_at)
|
||||||
|
values (fixture_session, fixture_uid, now(), now());
|
||||||
|
perform public._ensure_auth_user(fixture_email, 'Session Admin Test', 'different-ticket');
|
||||||
|
if not exists (select 1 from auth.sessions where id = fixture_session) or
|
||||||
|
not exists (select 1 from auth.users where id = fixture_uid and encrypted_password = previous_hash) then
|
||||||
|
raise exception 'Admin password session changed during ticket sync';
|
||||||
|
end if;
|
||||||
|
raise notice 'PASS: existing admin password and session survive ticket changes';
|
||||||
|
end;
|
||||||
|
$test$;
|
||||||
|
|
||||||
|
rollback;
|
||||||