Fixed existing agreement logic

This commit is contained in:
olaven 2024-08-27 09:11:12 +02:00
parent 126563360d
commit e1ce604a66
1 changed files with 6 additions and 1 deletions

View File

@ -18,7 +18,12 @@ export const handler = async function (req: Request): Promise<Response> {
} }
const existingAgreement = await storage.readVippsAgreement({ id: email }); 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); console.error("Agreement already exists", email);
return Response.redirect(errorPage); return Response.redirect(errorPage);
} }