diff --git a/apps/passport-client/components/screens/LoginScreens/OneClickLoginScreen.tsx b/apps/passport-client/components/screens/LoginScreens/OneClickLoginScreen.tsx index 220d61fe98..d3e61a8200 100644 --- a/apps/passport-client/components/screens/LoginScreens/OneClickLoginScreen.tsx +++ b/apps/passport-client/components/screens/LoginScreens/OneClickLoginScreen.tsx @@ -16,7 +16,7 @@ import { import { ScreenLoader } from "../../shared/ScreenLoader"; /** - * format: http://localhost:3000/#/one-click-login/:email/:code/:targetFolder + * format: http://localhost:3000/#/one-click-login/:email/:code/:targetFolder/:pipelineId?/:serverUrl? * - `code` is the pretix or lemonade order code * - `email` is the email address of the ticket to whom the ticket was issued * - `targetFolder` is the folder to redirect to after login. optional. @@ -25,7 +25,7 @@ import { ScreenLoader } from "../../shared/ScreenLoader"; export function OneClickLoginScreen(): JSX.Element | null { const self = useSelf(); const dispatch = useDispatch(); - const { email, code, targetFolder } = useParams(); + const { email, code, targetFolder, pipelineId, serverUrl } = useParams(); const [ticketPreviews, setTicketPreviews] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(); @@ -44,9 +44,10 @@ export function OneClickLoginScreen(): JSX.Element | null { } try { const previewRes = await requestGenericIssuanceTicketPreviews( - appConfig.zupassServer, + serverUrl ?? appConfig.zupassServer, email, - code + code, + pipelineId ); setLoading(false); @@ -64,7 +65,7 @@ export function OneClickLoginScreen(): JSX.Element | null { } }); } - }, [dispatch, email, code]); + }, [email, code, serverUrl, pipelineId, dispatch]); const handleOneClickLogin = useCallback(async () => { if (!email || !code) { @@ -141,8 +142,8 @@ export function OneClickLoginScreen(): JSX.Element | null {
No tickets found
) : ( <> - {ticketPreviews.map((ticket) => ( - + {ticketPreviews.map((ticket, i) => ( + {ticket.eventName} ({ticket.ticketName}) diff --git a/apps/passport-client/pages/index.tsx b/apps/passport-client/pages/index.tsx index 6a237ee888..64adcff68e 100644 --- a/apps/passport-client/pages/index.tsx +++ b/apps/passport-client/pages/index.tsx @@ -145,7 +145,7 @@ function RouterImpl(): JSX.Element { } /> } /> } /> { checkGenericIssuanceServiceStarted(genericIssuanceService); const email = checkUrlParam(req, "email"); const orderCode = checkUrlParam(req, "orderCode"); + const pipelineId = req.params.pipelineId; const result = await genericIssuanceService.handleGetTicketPreview( email, - orderCode + orderCode, + pipelineId ); res.json(result satisfies TicketPreviewResultValue); diff --git a/apps/passport-server/src/services/generic-issuance/GenericIssuanceService.ts b/apps/passport-server/src/services/generic-issuance/GenericIssuanceService.ts index 07bdbef324..1a8ef16848 100644 --- a/apps/passport-server/src/services/generic-issuance/GenericIssuanceService.ts +++ b/apps/passport-server/src/services/generic-issuance/GenericIssuanceService.ts @@ -351,28 +351,29 @@ export class GenericIssuanceService { public async handleGetTicketPreview( email: string, - orderCode: string + orderCode: string, + pipelineId?: string ): Promise { - const devconPipelineId = process.env.DEVCON_PIPELINE_ID; - const devconPipeline = (await this.getAllPipelineInstances()).find( - (p) => p.id === devconPipelineId && PretixPipeline.is(p) + const requestedPipelineId = pipelineId ?? process.env.DEVCON_PIPELINE_ID; + const pipeline = (await this.getAllPipelineInstances()).find( + (p) => p.id === requestedPipelineId && PretixPipeline.is(p) ) as PretixPipeline | undefined; - if (!devconPipeline) { + if (!pipeline) { throw new PCDHTTPError( 400, - "devcon pipeline not found " + devconPipelineId + "handleGetTicketPreview: pipeline not found " + requestedPipelineId ); } - const tickets = await devconPipeline.getAllTickets(); + const tickets = await pipeline.getAllTickets(); const matchingTickets = tickets.atoms.filter( (atom) => atom.email === email && atom.orderCode === orderCode ); const ticketDatas = matchingTickets.map((atom) => - devconPipeline.atomToPODTicketData(atom, "1234") + pipeline.atomToPODTicketData(atom, "1") ); return { diff --git a/packages/lib/passport-interface/src/api/requestGenericIssuanceTicketPreviews.ts b/packages/lib/passport-interface/src/api/requestGenericIssuanceTicketPreviews.ts index f5af75965f..9538575f6c 100644 --- a/packages/lib/passport-interface/src/api/requestGenericIssuanceTicketPreviews.ts +++ b/packages/lib/passport-interface/src/api/requestGenericIssuanceTicketPreviews.ts @@ -4,14 +4,13 @@ import { APIResult } from "./apiResult"; import { httpGetSimple } from "./makeRequest"; /** - * Asks the server to fetch the pipeline definition corresponding to the - * given pipeline ID. Requires cookies, as this is part of generic issuance - * user authentication. + * Asks the server to fetch the ticket previews for the given email and order code. */ export async function requestGenericIssuanceTicketPreviews( zupassServerUrl: string, email: string, - orderCode: string + orderCode: string, + pipelineId?: string ): Promise { return httpGetSimple( urlJoin( @@ -19,7 +18,7 @@ export async function requestGenericIssuanceTicketPreviews( `/generic-issuance/api/ticket-previews`, encodeURIComponent(email), encodeURIComponent(orderCode) - ), + ) + (pipelineId ? `/${pipelineId}` : ""), async (resText) => ({ value: JSON.parse(resText) as TicketPreviewResultValue, success: true