diff --git a/keyserver/src/user/identity.js b/keyserver/src/user/identity.js --- a/keyserver/src/user/identity.js +++ b/keyserver/src/user/identity.js @@ -125,6 +125,18 @@ return dbQuery(updateQuery); } +async function clearMetadata(keys: $ReadOnlyArray): Promise { + if (keys.length === 0) { + return; + } + const deleteQuery = SQL` + DELETE FROM metadata + WHERE name IN (${keys}) + `; + + await dbQuery(deleteQuery); +} + function saveIdentityInfo(userInfo: IdentityInfo): Promise { const metadataMap = new Map(); metadataMap.set(metadataKeys.USER_ID, userInfo.userId); @@ -133,10 +145,16 @@ return saveMetadata(metadataMap); } +async function clearIdentityInfo(): Promise { + const keys = [metadataKeys.USER_ID, metadataKeys.ACCESS_TOKEN]; + await clearMetadata(keys); +} + export { fetchIdentityInfo, thisKeyserverID, thisKeyserverAdmin, saveIdentityInfo, + clearIdentityInfo, isAuthoritativeKeyserver, };