Regression: Fix login screen reactivity of external login providers (#19033)

pull/19002/head^2
Rodrigo Nascimento 5 years ago committed by GitHub
parent 7a7a5e8b67
commit 2ee3bc410d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 25
      app/lib/server/startup/userDataStream.js
  2. 7
      app/models/server/models/LoginServiceConfiguration.js

@ -2,6 +2,7 @@ import { MongoInternals } from 'meteor/mongo';
import { Users } from '../../../models/server';
import { Notifications } from '../../../notifications/server';
import loginServiceConfiguration from '../../../models/server/models/LoginServiceConfiguration';
let processOnChange;
// eslint-disable-next-line no-undef
@ -10,6 +11,7 @@ const disableOplog = Package['disable-oplog'];
if (disableOplog) {
// Stores the callbacks for the disconnection reactivity bellow
const userCallbacks = new Map();
const serviceConfigCallbacks = new Set();
// Overrides the native observe changes to prevent database polling and stores the callbacks
// for the users' tokens to re-implement the reactivity based on our database listeners
@ -32,11 +34,17 @@ if (disableOplog) {
userCallbacks.set(selector._id, cbs);
}
}
if (collectionName === 'meteor_accounts_loginServiceConfiguration') {
serviceConfigCallbacks.add(callbacks);
}
return {
stop() {
if (cbs) {
cbs.delete(callbacks);
}
serviceConfigCallbacks.delete(callbacks);
},
};
};
@ -57,6 +65,23 @@ if (disableOplog) {
}
}
};
loginServiceConfiguration.on('change', ({ clientAction, id, data, diff }) => {
switch (clientAction) {
case 'inserted':
case 'updated':
const record = { ...data || diff };
delete record.secret;
serviceConfigCallbacks.forEach((callbacks) => {
callbacks[clientAction === 'inserted' ? 'added' : 'changed']?.(id, record);
});
break;
case 'removed':
serviceConfigCallbacks.forEach((callbacks) => {
callbacks.removed?.(id);
});
}
});
}
Users.on('change', ({ clientAction, id, data, diff }) => {

@ -0,0 +1,7 @@
import { ServiceConfiguration } from 'meteor/service-configuration';
import { Base } from './_Base';
export class LoginServiceConfiguration extends Base {}
export default new LoginServiceConfiguration(ServiceConfiguration.configurations, { preventSetUpdatedAt: true });
Loading…
Cancel
Save