From 47e35d0b06ec33f19e7f3782bd9d32abe2b39393 Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Thu, 9 Mar 2023 18:59:04 +0100 Subject: [PATCH] Support consume api --- src/oidc.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/oidc.js b/src/oidc.js index e1dc057b1..29ad10196 100644 --- a/src/oidc.js +++ b/src/oidc.js @@ -55,7 +55,7 @@ class CloudronAdapter { async upsert(id, payload, expiresIn) { debug(`[${this.name}] upsert id:${id} expiresIn:${expiresIn}`, payload); - this.store[id] = payload; + this.store[id] = { id, expiresIn, payload, consumed: false }; fs.writeFileSync(this.fileStorePath, JSON.stringify(this.store), 'utf8'); } @@ -74,7 +74,7 @@ class CloudronAdapter { if (!this.store[id]) return false; - return this.store[id]; + return this.store[id].payload; } /** @@ -106,7 +106,7 @@ class CloudronAdapter { debug(`[${this.name}] findByUid uid:${uid}`); for (let d in this.store) { - if (this.store[d].uid === uid) return this.store[d]; + if (this.store[d].uid === uid) return this.store[d].payload; } return false; @@ -124,7 +124,9 @@ class CloudronAdapter { * */ async consume(id) { - debug(`[${this.name}] FIXME consume id:${id}`); + debug(`[${this.name}] consume id:${id}`); + + if (this.store[id]) this.store[id].consumed = true; } /**