Page MenuHomePhabricator

D6060.id20203.diff
No OneTemporary

D6060.id20203.diff

diff --git a/keyserver/src/fetchers/user-fetchers.js b/keyserver/src/fetchers/user-fetchers.js
--- a/keyserver/src/fetchers/user-fetchers.js
+++ b/keyserver/src/fetchers/user-fetchers.js
@@ -290,6 +290,18 @@
return result[0].user;
}
+async function fetchUserIDForEthereumAddress(
+ address: string,
+): Promise<?string> {
+ const query = SQL`
+ SELECT id
+ FROM users
+ WHERE LCASE(ethereum_address) = LCASE(${address})
+ `;
+ const [result] = await dbQuery(query);
+ return result.length === 0 ? null : result[0].id;
+}
+
export {
fetchUserInfos,
fetchLoggedInUserInfo,
@@ -300,4 +312,5 @@
fetchUsername,
fetchKnownUserInfos,
fetchKeyserverAdminID,
+ fetchUserIDForEthereumAddress,
};
diff --git a/keyserver/src/responders/user-responders.js b/keyserver/src/responders/user-responders.js
--- a/keyserver/src/responders/user-responders.js
+++ b/keyserver/src/responders/user-responders.js
@@ -55,6 +55,7 @@
import {
fetchKnownUserInfos,
fetchLoggedInUserInfo,
+ fetchUserIDForEthereumAddress,
} from '../fetchers/user-fetchers';
import {
createNewAnonymousCookie,
@@ -355,6 +356,12 @@
}
}
+ // 4. Complete login with call to `successfulLogInQueries`
+ // if `address` corresponds to an existing user.
+ const userID = await fetchUserIDForEthereumAddress(siweMessage.address);
+ if (userID) {
+ successfulLogInQueries(viewer, input, userID);
+ }
return false;
}

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 27, 12:57 PM (7 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2713410
Default Alt Text
D6060.id20203.diff (1 KB)

Event Timeline