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,17 @@ return dbQuery(updateQuery); } +function clearMetadata( + keys: $ReadOnlyArray, +): Promise { + const deleteQuery = SQL` + DELETE FROM metadata + WHERE name IN (${keys}) + `; + + return dbQuery(deleteQuery); +} + function saveIdentityInfo(userInfo: IdentityInfo): Promise { const metadataMap = new Map(); metadataMap.set(metadataKeys.USER_ID, userInfo.userId); @@ -133,10 +144,16 @@ return saveMetadata(metadataMap); } +function clearIdentityInfo(): Promise { + const keys = [metadataKeys.USER_ID, metadataKeys.ACCESS_TOKEN]; + return clearMetadata(keys); +} + export { fetchIdentityInfo, thisKeyserverID, thisKeyserverAdmin, saveIdentityInfo, + clearIdentityInfo, isAuthoritativeKeyserver, };