1
0
Fork 0

fix(backend): Avoid async issues when returning key list

This commit is contained in:
joostdecock 2023-08-21 09:13:34 +02:00
parent f3584eee43
commit 06bcf8a656

View file

@ -165,9 +165,14 @@ ApikeyModel.prototype.userApikeys = async function (uid) {
} }
/* /*
* Keys are an array, remove sercrets with map() and decrypt prior to returning * Keys are an array, remove secrets with map() and decrypt prior to returning
*/ */
return keys.map((key) => this.asKeyData(key)) const list = []
for (const key of keys) {
list.push(await this.asKeyData(key))
}
return list
} }
/* /*
@ -176,7 +181,7 @@ ApikeyModel.prototype.userApikeys = async function (uid) {
ApikeyModel.prototype.asKeyData = async function (key) { ApikeyModel.prototype.asKeyData = async function (key) {
delete key.secret delete key.secret
delete key.aud delete key.aud
key.name = this.decrypt(key.name) key.name = await this.decrypt(key.name)
return key return key
} }