Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function renderApp(res: ServerResponse, store: Store, assets?: Object, renderProps?: Object) {
Fiber(() => Meteor.bindEnvironment(() => {
const location = renderProps && renderProps.location && renderProps.location.pathname || '/'
// Needed so some components can render based on location
store.dispatch(push(location))
const htmlStream = renderToStaticMarkup(
)
res.write('')
htmlStream.pipe(res, {end: false})
htmlStream.on('end', (): void => res.end())
})()).run()
}
const logOutUser = function(samlInfo) {
const loggedOutUser = Meteor.users.find({
$or: [
{ 'services.saml.nameID': samlInfo.nameID },
{ 'services.saml.idpSession': samlInfo.idpSession },
],
}).fetch();
if (loggedOutUser.length === 1) {
logoutRemoveTokens(loggedOutUser[0]._id);
}
};
fiber(function() {
logOutUser(result);
}).run();
const { response } = _saml.generateLogoutResponse({
nameID: result.nameID,
sessionIndex: result.idpSession,
});
_saml.logoutResponseToUrl(response, function(err, url) {
if (err) {
console.error(err);
throw new Meteor.Error('Unable to generate SAML logout Response Url');
}
res.writeHead(302, {
Location: url,
function handle() {
Fiber(() => handleJSONRequest(req, res, next))
.run();
}
delete() {
if (!this._requestPath.collectionId) {
return this._notFoundResponse('Missing _id');
}
return fibers(() => {
try {
const returnObject = getReturnObject();
if (!this._beforeHandling(
'DELETE',
this._requestCollection.findOne(this._requestPath.collectionId),
this._requestPath,
returnObject
)) {
return this._rejectedResponse('Could not delete that object.');
}
if (this._handleReturnObject('DELETE', returnObject)) {
return true;
}
return function () {
const self = this;
Fiber(function () {
fn.call(self);
}).run();
};
}
let retryPromise = promiseRetry(retry => {
try {
Fiber(() => {
return Email.send(mailOptions);
}).run();
} catch (error) {
retry(error);
}
}, retryOptions);
function(req, res, next) {
Fiber(function() {
const userId = getUserIdFromAuthToken(req.authToken);
if (userId) {
req.userId = userId;
}
next();
}).run();
};
return this._request.on('end', () => {
fibers(() => {
try {
const obj = JSON.parse(requestData);
const returnObject = getReturnObject();
if (!this._beforeHandling(
'PUT',
this._requestCollection.findOne(this._requestPath.collectionId),
obj,
this._requestPath,
returnObject
)) {
return this._rejectedResponse('Could not put that object.');
}
if (this._handleReturnObject('PUT', returnObject)) {
check(sourceId, String);
check(options, Match.Optional({ skipGlobalStats: Match.Optional(Boolean), token: Match.Optional(String) }));
const source = Sources.findOne(sourceId);
if (!source) {
throw new Meteor.Error(404, 'Not found');
}
if (!options || !options.token || options.token !== Meteor.settings.ddpClientToken) {
if (!this.userId) {
throw new Meteor.Error(401, 'Please log in first.');
}
if (!source.editableBy(this.userId)) {
throw new Meteor.Error(402, 'Not authorized');
}
}
this.unblock();
Fiber(() => {
source.generateAndSaveStats(options);
}).run();
},
});