Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Meteor 3] Fix OAuth methods #13050

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/accounts-base/accounts_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ export class AccountsServer extends AccountsCommon {

// Allow a one-time configuration for a login service. Modifications
// to this collection are also allowed in insecure mode.
methods.configureLoginService = (options) => {
methods.configureLoginService = async (options) => {
check(options, Match.ObjectIncluding({service: String}));
// Don't let random users configure a service we haven't added yet (so
// that when we do later add it, it's set up with their configuration
Expand All @@ -731,7 +731,8 @@ export class AccountsServer extends AccountsCommon {

if (Package['service-configuration']) {
const { ServiceConfiguration } = Package['service-configuration'];
if (ServiceConfiguration.configurations.findOneAsync({service: options.service}))
const service = await ServiceConfiguration.configurations.findOneAsync({service: options.service})
if (service)
throw new Meteor.Error(403, `Service ${options.service} already configured`);

if (Package["oauth-encryption"]) {
Expand All @@ -740,7 +741,7 @@ export class AccountsServer extends AccountsCommon {
options.secret = OAuthEncryption.seal(options.secret);
}

ServiceConfiguration.configurations.insert(options);
await ServiceConfiguration.configurations.insertAsync(options);
}
};

Expand Down
4 changes: 2 additions & 2 deletions packages/accounts-oauth/oauth_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ Meteor.startup(() => {
}, {
"secret.algorithm": { $exists: false }
}]
}).forEach(config => {
ServiceConfiguration.configurations.update(config._id, {
}).forEachAsync(async (config) => {
nachocodoner marked this conversation as resolved.
Show resolved Hide resolved
await ServiceConfiguration.configurations.updateAsync(config._id, {
$set: {
secret: OAuthEncryption.seal(config.secret)
}
Expand Down
8 changes: 4 additions & 4 deletions packages/accounts-ui-unstyled/login_buttons_dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ const isInPasswordSignupFields = (fieldOrFields) => {
return signupFields.reduce(
(prev, field) => prev && fieldOrFields.includes(field),
true,
)
);
}

return signupFields.includes(fieldOrFields);
Expand Down Expand Up @@ -488,7 +488,7 @@ Template._loginButtonsLoggedOutPasswordlessService.helpers({
inSignupFlow: () => loginButtonsSession.get('inSignupFlow'),

showCreateAccountLink: () => !Accounts._options.forbidClientAccountCreation,
})
});

Template._loginButtonsLoggedOutPasswordService.helpers({
fields: () => {
Expand Down Expand Up @@ -565,7 +565,7 @@ Template._loginButtonsLoggedOutPasswordService.helpers({

Template._loginButtonsFormField.helpers({
inputType: function () {
return this.inputType || "text"
return this.inputType || "text";
}
});

Expand All @@ -584,7 +584,7 @@ Template._loginButtonsChangePassword.events({

Template._loginButtonsChangePassword.helpers({
fields: () => {
const { username, emails } = Meteor.user()
const { username, emails } = Meteor.user();
let email;
if (emails) {
email = emails[0].address;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ try {
Meteor.startup(() => {
const settings = Meteor.settings?.packages?.['service-configuration'];
if (!settings) return;
Object.keys(settings).forEach(key => {
ServiceConfiguration.configurations.upsert(
for (const key of Object.keys(settings)) {
ServiceConfiguration.configurations.upsertAsync(
{ service: key },
{
$set: settings[key],
}
);
});
}
});