diff --git a/packages/web-app/app/_server/idos/idos-grantee.ts b/packages/web-app/app/_server/idos/idos-grantee.ts index 49e193a7..a88cd8de 100644 --- a/packages/web-app/app/_server/idos/idos-grantee.ts +++ b/packages/web-app/app/_server/idos/idos-grantee.ts @@ -157,13 +157,15 @@ export class idOSGrantee { ); } - async fetchUserCountryFromSharedCredential( + async fetchUserCountryFromSharedPlusCredential( dataId: string, ): Promise { const credentialString = await this.getSharedCredentialContentDecrypted(dataId); const credential = JSON.parse(credentialString); + if (credential?.level !== 'plus') return undefined; + return credential?.credentialSubject?.residential_address_country; } diff --git a/packages/web-app/app/_server/idos/index.ts b/packages/web-app/app/_server/idos/index.ts index d7d8d778..25c22a4e 100644 --- a/packages/web-app/app/_server/idos/index.ts +++ b/packages/web-app/app/_server/idos/index.ts @@ -40,13 +40,13 @@ const userFilter = async (grantee: idOSGrantee, userAddress: string) => { .parse(grantsResult) ?.filter((grant) => isValidGrant(grant.lockedUntil)); - if (!grants.length) throw new Error('No valid grants found'); + if (!grants.length) return null; - const country = await grantee.fetchUserCountryFromSharedCredential( + const country = await grantee.fetchUserCountryFromSharedPlusCredential( grants[0].dataId, ); - if (!country) throw new Error('No country found'); + if (!country) return null; const isBlockedCountry = blockedCountries.some( (blockedCountry) => blockedCountry === country,