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; } /**