Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33017546
D6998.1768380507.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D6998.1768380507.diff
View Options
diff --git a/keyserver/src/cron/compare-users.js b/keyserver/src/cron/compare-users.js
--- a/keyserver/src/cron/compare-users.js
+++ b/keyserver/src/cron/compare-users.js
@@ -1,29 +1,40 @@
// @flow
+import { getRustAPI } from 'rust-node-addon';
import { deleteCookies } from '../deleters/cookie-deleters.js';
import { fetchNativeCookieIDsForUserIDs } from '../fetchers/cookie-fetchers.js';
import { fetchAllUserIDs } from '../fetchers/user-fetchers.js';
async function compareMySQLUsersToIdentityService(): Promise<void> {
- // eslint-disable-next-line no-unused-vars
- const allUserIDs = await fetchAllUserIDs();
- // next we need to query identity service for two things:
- // 1. users in identity that aren't here
- // 2. users here that aren't in identity
- const userMissingFromKeyserver = [];
- const userMissingFromIdentity = [];
- if (userMissingFromKeyserver.length > 0) {
+ const [allUserIDs, rustAPI] = await Promise.all([
+ fetchAllUserIDs(),
+ getRustAPI(),
+ ]);
+ const userComparisonResult = await rustAPI.compareUsers(allUserIDs);
+ const { usersMissingFromKeyserver, usersMissingFromIdentity } =
+ userComparisonResult;
+
+ if (usersMissingFromKeyserver.length > 0) {
console.warn(
"found users in identity service that aren't in MySQL! " +
- JSON.stringify(userMissingFromKeyserver),
+ JSON.stringify(usersMissingFromKeyserver),
);
}
- if (userMissingFromIdentity.length === 0) {
+ if (usersMissingFromIdentity.length === 0) {
return;
}
const cookieIDs = await fetchNativeCookieIDsForUserIDs(
- userMissingFromIdentity,
+ usersMissingFromIdentity,
);
+ if (cookieIDs.length === 0) {
+ return;
+ }
+
+ // By deleting a cookie associated with a user's device, we trigger an
+ // auto-log-in from that device, which lets us access the user's password. We
+ // need the password in order to double-write user data to the identity
+ // service. We only delete cookies associated with native devices because we
+ // don't cache passwords on other platforms.
await deleteCookies(cookieIDs);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 14, 8:48 AM (12 m, 6 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5928713
Default Alt Text
D6998.1768380507.diff (2 KB)
Attached To
Mode
D6998: [keyserver] update compare-user.js to get missing users by querying identity service
Attached
Detach File
Event Timeline
Log In to Comment