mirror of
https://github.com/documenso/documenso.git
synced 2026-07-27 02:15:05 +10:00
fix: handle invalid qr share tokens without 500 (#2597)
This commit is contained in:
@@ -202,6 +202,15 @@ test.describe('PDF Viewer Rendering', () => {
|
|||||||
await page.getByRole('button', { name: /Page 2/ }).click();
|
await page.getByRole('button', { name: /Page 2/ }).click();
|
||||||
await expect(page.locator(PDF_PAGE_SELECTOR).first()).toBeVisible({ timeout: 30_000 });
|
await expect(page.locator(PDF_PAGE_SELECTOR).first()).toBeVisible({ timeout: 30_000 });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should not return 500 for invalid QR share token', async ({ page }) => {
|
||||||
|
const response = await page.request.get('/share/qr_invalid_token_for_regression_check', {
|
||||||
|
maxRedirects: 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(response.status()).toBe(302);
|
||||||
|
expect(response.headers().location).toBe('/');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test.describe('Embed Pages', () => {
|
test.describe('Embed Pages', () => {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export const getDocumentByAccessToken = async ({ token }: GetDocumentByAccessTok
|
|||||||
throw new Error('Missing token');
|
throw new Error('Missing token');
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await prisma.envelope.findFirstOrThrow({
|
const result = await prisma.envelope.findFirst({
|
||||||
where: {
|
where: {
|
||||||
type: EnvelopeType.DOCUMENT,
|
type: EnvelopeType.DOCUMENT,
|
||||||
status: DocumentStatus.COMPLETED,
|
status: DocumentStatus.COMPLETED,
|
||||||
@@ -56,6 +56,14 @@ export const getDocumentByAccessToken = async ({ token }: GetDocumentByAccessTok
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!result) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.envelopeItems.length === 0) {
|
||||||
|
throw new Error('Completed envelope has no items');
|
||||||
|
}
|
||||||
|
|
||||||
const firstDocumentData = result.envelopeItems[0].documentData;
|
const firstDocumentData = result.envelopeItems[0].documentData;
|
||||||
|
|
||||||
if (!firstDocumentData) {
|
if (!firstDocumentData) {
|
||||||
|
|||||||
Reference in New Issue
Block a user