corrections found while writing documentation
This commit is contained in:
parent
5485eb9260
commit
ab22ebc967
17 changed files with 127 additions and 42 deletions
|
|
@ -1,14 +1,30 @@
|
|||
import { Meteor } from 'meteor/meteor';
|
||||
import { check } from 'meteor/check';
|
||||
import { ServiceConfiguration } from 'meteor/service-configuration';
|
||||
import rateLimit from '../../../modules/rate-limit';
|
||||
|
||||
Meteor.methods({
|
||||
'oauth.verifyConfiguration': function oauthVerifyConfiguration(services) {
|
||||
check(services, Array);
|
||||
const verifiedServices = [];
|
||||
services.forEach((service) => {
|
||||
if (ServiceConfiguration.configurations.findOne({ service })) verifiedServices.push(service);
|
||||
});
|
||||
return verifiedServices.sort();
|
||||
|
||||
try {
|
||||
const verifiedServices = [];
|
||||
services.forEach((service) => {
|
||||
if (ServiceConfiguration.configurations.findOne({ service })) {
|
||||
verifiedServices.push(service);
|
||||
}
|
||||
});
|
||||
return verifiedServices.sort();
|
||||
} catch (exception) {
|
||||
throw new Meteor.Error('500', exception);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
rateLimit({
|
||||
methods: [
|
||||
'oauth.verifyConfiguration',
|
||||
],
|
||||
limit: 5,
|
||||
timeRange: 1000,
|
||||
});
|
||||
|
|
|
|||
43
imports/api/Users/server/edit-profile.js
Normal file
43
imports/api/Users/server/edit-profile.js
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/* eslint-disable consistent-return */
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { Accounts } from 'meteor/accounts-base';
|
||||
|
||||
let action;
|
||||
|
||||
const updatePassword = (userId, newPassword) => {
|
||||
try {
|
||||
Accounts.setPassword(userId, newPassword, { logout: false });
|
||||
} catch (exception) {
|
||||
action.reject(`[editProfile.updatePassword] ${exception}`);
|
||||
}
|
||||
};
|
||||
|
||||
const updateUser = (userId, { emailAddress, profile }) => {
|
||||
try {
|
||||
Meteor.users.update(userId, {
|
||||
$set: {
|
||||
'emails.0.address': emailAddress,
|
||||
profile,
|
||||
},
|
||||
});
|
||||
} catch (exception) {
|
||||
action.reject(`[editProfile.updateUser] ${exception}`);
|
||||
}
|
||||
};
|
||||
|
||||
const editProfile = ({ userId, profile }, promise) => {
|
||||
try {
|
||||
action = promise;
|
||||
|
||||
updateUser(userId, profile);
|
||||
if (profile.password) updatePassword(userId, profile.password);
|
||||
|
||||
action.resolve();
|
||||
} catch (exception) {
|
||||
action.reject(`[editProfile.handler] ${exception}`);
|
||||
}
|
||||
};
|
||||
|
||||
export default options =>
|
||||
new Promise((resolve, reject) =>
|
||||
editProfile(options, { resolve, reject }));
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { Meteor } from 'meteor/meteor';
|
||||
import { check, Match } from 'meteor/check';
|
||||
import editProfile from '../../../modules/server/edit-profile';
|
||||
import editProfile from './edit-profile';
|
||||
import rateLimit from '../../../modules/rate-limit';
|
||||
|
||||
Meteor.methods({
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import getPrivateFile from '../../../modules/server/get-private-file';
|
|||
import parseMarkdown from '../../../modules/parse-markdown';
|
||||
|
||||
Meteor.methods({
|
||||
'utility.getPage': function utilityReadFileAsText(fileName) {
|
||||
'utility.getPage': function utilityGetPage(fileName) {
|
||||
check(fileName, String);
|
||||
return parseMarkdown(getPrivateFile(`pages/${fileName}.md`));
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue