@@ -165,6 +165,15 @@ export default class OBPConsentsService {
165165 }
166166 }
167167
168+ async checkConsentExpired ( consent : any ) : Promise < boolean > { //DEBUG
169+ // Check if the consent is expired
170+ // Decode the JWT and check the exp field
171+
172+ const exp = consent . jwt_payload . exp
173+ const now = Math . floor ( Date . now ( ) / 1000 )
174+ return exp < now
175+ }
176+
168177 async getExistingOpeyConsentId ( session : Session ) : Promise < any > {
169178 // Get Consents for the current user, check if any of them are for Opey
170179 // If so, return the consent
@@ -186,8 +195,10 @@ export default class OBPConsentsService {
186195 throw new Error ( 'User is not logged in' )
187196 }
188197
189-
190- const consentInfosPath = '/obp/v5.1.0/my/consent-infos'
198+ // We need to change this back to consent infos once OBP shows 'EXPIRED' in the status
199+ // Right now we have to check the JWT ourselves
200+ const consentInfosPath = '/obp/v5.1.0/my/consents'
201+ //const consentInfosPath = '/obp/v5.1.0/my/consent-infos'
191202
192203 let opeyConsentId : string | null = null
193204 try {
@@ -199,11 +210,15 @@ export default class OBPConsentsService {
199210 throw new Error ( 'Opey Consumer ID is missing, please set VITE_OPEY_CONSUMER_ID' )
200211 }
201212
202- console . log ( 'consents data: \n' , response . data ) //DEBUG
203-
204213 for ( const consent of consents ) {
205214 console . log ( `consent_consumer_id: ${ consent . consumer_id } , opey_consumer_id: ${ opeyConsumerID } \n consent_status: ${ consent . status } ` ) //DEBUG
206215 if ( consent . consumer_id === opeyConsumerID && consent . status === 'ACCEPTED' ) {
216+ // Check if the consent is expired
217+ const isExpired = await this . checkConsentExpired ( consent )
218+ if ( isExpired ) {
219+ console . log ( 'getExistingConsent: Consent is expired' )
220+ continue
221+ }
207222 opeyConsentId = consent . consent_id
208223 break
209224 }
0 commit comments