Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,27 @@ describe('OTP verification and validation', () => {

await waitFor(() => expect(localStorage.getItem('token')).toBe('otp-token'));
expect(await screen.findByText('OTP validated successfully')).toBeInTheDocument();
await expectCodeVisible('UNUSED-CODE');
});

it('loads invites after 2FA even when no token is returned', async () => {
server.use(
http.post(`${API_HOST}/api/auth/login`, () =>
HttpResponse.json({ otp_enabled: true, otp_verified: true })
),
http.post(`${API_HOST}/api/auth/otp/validate`, () => HttpResponse.json({}))
);

render(<App />);
fillLogin('twofa');
await waitFor(() =>
expect(screen.getByText('Two-Factor Authentication')).toBeInTheDocument()
);

fireEvent.change(screen.getByPlaceholderText('000000'), { target: { value: '123456' } });
fireEvent.click(screen.getByRole('button', { name: 'Validate' }));

await expectCodeVisible('UNUSED-CODE');
});
});

Expand Down Expand Up @@ -438,7 +459,7 @@ describe('used-by handle', () => {
expect(link).toHaveAttribute('href', 'https://bsky.app/profile/alice.bsky.social');
});

it('falls back to a dash when the API returns no handle', async () => {
it('falls back to the DID when the API returns no handle', async () => {
const noHandle = [
{ ...didInvites[0], uses: [{ usedBy: 'did:plc:abc', usedAt: '2026-01-25T08:12:55.280Z' }] },
];
Expand All @@ -450,6 +471,8 @@ describe('used-by handle', () => {

await expectCodeVisible('DID-CODE');
expect(screen.queryByRole('link', { name: 'alice.bsky.social' })).not.toBeInTheDocument();
const link = screen.getAllByRole('link', { name: 'did:plc:abc' })[0];
expect(link).toHaveAttribute('href', 'https://bsky.app/profile/did:plc:abc');
});
});

Expand Down
32 changes: 13 additions & 19 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,8 @@ function App() {
URL.revokeObjectURL(url);
};

const isAdminPage = page === 'Admins';
useEffect(() => {
if (!token) {
if (page !== 'Home' && page !== 'Admins') {
return;
}
let cancelled = false;
Expand All @@ -433,7 +432,7 @@ function App() {
return () => {
cancelled = true;
};
}, [token, isAdminPage, fetchInvites, fetchAdmins]);
}, [page, fetchInvites, fetchAdmins]);

useEffect(() => {
if (!notice) {
Expand Down Expand Up @@ -836,7 +835,7 @@ function App() {
const status = getStatus(invite);
const usedAt = getUsedAt(invite);
const usedBy = getUsedBy(invite);
const resolvedHandle = getUsedByHandle(invite);
const usedByLabel = getUsedByHandle(invite) || usedBy;
const accountStatus = getAccountStatus(invite);
return (
<tr
Expand Down Expand Up @@ -874,14 +873,14 @@ function App() {
</td>
<td className="px-3 py-4 text-sm text-gray-500 dark:text-gray-400">
<div className="flex items-center gap-2">
{resolvedHandle ? (
{usedByLabel ? (
<a
href={`https://bsky.app/profile/${resolvedHandle}`}
href={`https://bsky.app/profile/${usedByLabel}`}
target="_blank"
rel="noopener noreferrer"
className="text-blue-600 hover:underline"
>
{resolvedHandle}
{usedByLabel}
</a>
) : (
'-'
Expand All @@ -902,14 +901,9 @@ function App() {
<td className="px-3 py-4 text-sm text-gray-500 dark:text-gray-400 max-w-[14rem] truncate">
{invite.uses?.[0]?.usedByEmail || '-'}
</td>
<td className="px-3 py-4 text-sm text-gray-500 dark:text-gray-400">
<td className="px-3 py-4 text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">
{usedBy ? (
<span
className="font-mono text-xs block max-w-[12rem] truncate"
title={usedBy}
>
{usedBy}
</span>
<span className="font-mono text-xs">{usedBy}</span>
) : (
'-'
)}
Expand Down Expand Up @@ -942,7 +936,7 @@ function App() {
const status = getStatus(invite);
const usedAt = getUsedAt(invite);
const usedBy = getUsedBy(invite);
const resolvedHandle = getUsedByHandle(invite);
const usedByLabel = getUsedByHandle(invite) || usedBy;
const accountStatus = getAccountStatus(invite);
return (
<div
Expand Down Expand Up @@ -1001,14 +995,14 @@ function App() {
Used By
</p>
<p className="dark:text-gray-300 truncate">
{resolvedHandle ? (
{usedByLabel ? (
<a
href={`https://bsky.app/profile/${resolvedHandle}`}
href={`https://bsky.app/profile/${usedByLabel}`}
target="_blank"
rel="noopener noreferrer"
className="text-blue-600 hover:underline"
>
{resolvedHandle}
{usedByLabel}
</a>
) : (
'-'
Expand All @@ -1030,7 +1024,7 @@ function App() {
<p className="text-gray-500 dark:text-gray-400 text-xs uppercase font-semibold">
DID
</p>
<p className="dark:text-gray-300 font-mono text-xs truncate" title={usedBy}>
<p className="dark:text-gray-300 font-mono text-xs break-all">
{usedBy || '-'}
</p>
</div>
Expand Down