From e1ce604a66ff5c41d249f62feda6b0f87baf5267 Mon Sep 17 00:00:00 2001 From: olaven Date: Tue, 27 Aug 2024 09:11:12 +0200 Subject: [PATCH] Fixed existing agreement logic --- routes/api/trigger-donation/vipps.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/routes/api/trigger-donation/vipps.ts b/routes/api/trigger-donation/vipps.ts index 76b44e4..7d20900 100644 --- a/routes/api/trigger-donation/vipps.ts +++ b/routes/api/trigger-donation/vipps.ts @@ -18,7 +18,12 @@ export const handler = async function (req: Request): Promise { } const existingAgreement = await storage.readVippsAgreement({ id: email }); - if (existingAgreement && existingAgreement.revokedAt === null) { + const hasActiveAgreement = existingAgreement && + existingAgreement.validAt !== null && + existingAgreement.revokedAt === null; + if ( + hasActiveAgreement + ) { console.error("Agreement already exists", email); return Response.redirect(errorPage); }