Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3544492
D6060.id20203.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D6060.id20203.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D6060: [keyserver] Introduce `fetchUserIDForEthereumAddress` and use in `siweAuthResponder`
Attached
Detach File
Event Timeline
Log In to Comment