Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'NotOrdered': function NotOrdered(event, commit, deps){
if(event.eventType === 'OrderPlaced'){
// Start packaging the order from which the event came.
return deps.startPackaging(commit.sequenceID).then(function(){
return when.resolve(new Event('OrderPlaced', {
orderID: commit.sequenceID
}));
});
}
else{
return when.reject();
}
},
'Ordered': function Ordered(event, commit, deps){
_getIpAddress: function(ipOrDomain) {
if (ipOrDomain === 'mine') {
var ips = utilities.getIPAddresses();
if (ips.length === 1) {
return ips[0];
} else if (ips.length > 0) {
// TODO show selector?
return when.reject('Multiple valid ip addresses');
} else {
return when.reject('No IP addresses');
}
}
return ipOrDomain;
}
});
return promisedFind.then(function (result) {
if (result.length === 0) {
return when.reject(new SystemNotification('error', 'Login or password is invalid.'));
}
var sessionID = uuid.v4();
var expirationTime = 60 * 60 * 24; // one hour
return when.promise(function (resolve, reject) {
deps.redis.client.setex('sessionID:' + sessionID, expirationTime, result[0]._id, function (error, result) {
if (error) {
reject(new SystemNotification('error', 'Error while setting key in redis.'));
return;
}
params.res.cookie('sessionID', sessionID, { expires: new Date(Date.now + (expirationTime * 1000)) });
resolve(new SystemNotification('notification', 'You are log in now.'));
});
});
}).catch(function (rejectMessage) {
return when.resolve(rejectMessage);
return tool.grib2json(args, process.stdout, process.stderr).then(function(returnCode) {
if (returnCode !== 0) {
log.info(util.format("grib2json failed (%s): %s", returnCode, productPath));
return when.reject(returnCode); // ?
}
work.forEach(function(item) {
if (!item.temp) {
return;
}
var layerPath = item.layer.path(opt.layerHome);
log.info("processing: " + layerPath);
var data = processLayer(item.layer, item.temp);
if (!data) {
log.info("no layer data, skipping: " + layerPath);
item.layer = null;
return;
}
mkdirp.sync(item.layer.dir(opt.layerHome));
fs.writeFileSync(layerPath, JSON.stringify(data, null, INDENT), {encoding: "utf8"});
return this.getByEmail(email).then(function (foundUser) {
if (!foundUser) {
return when.reject(new errors.NotFoundError('There is no user with that email address.'));
}
var hash = crypto.createHash('sha256'),
text = '';
// Token:
// BASE64(TIMESTAMP + email + HASH(TIMESTAMP + email + oldPasswordHash + dbHash ))
hash.update(String(expires));
hash.update(email.toLocaleLowerCase());
hash.update(foundUser.get('password'));
hash.update(String(dbHash));
text += [expires, email, hash.digest('base64')].join('|');
return new Buffer(text).toString('base64');
function() {
//only match against knownApp if file is not found
var stats;
try {
stats = fs.statSync(firmware);
} catch (ex) {
// file does not exist
firmware = dfu.checkKnownApp(firmware);
if (firmware === undefined) {
return when.reject('file does not exist and no known app found.');
} else {
flashingKnownApp = true;
return firmware;
}
}
if (!stats.isFile()){
return when.reject('You cannot flash a directory over USB');
}
},
function() {
sendDoctorClearEEPROM: function(device, timeout) {
if (!device) {
return when.reject('sendDoctorClearEEPROM - no serial port provided');
}
var command = 'e';
return this._issueSerialCommand(device, command, timeout).then(function (data) {
return data;
});
},
return function noRetry(error, operation){
if(isRecoverable(error)){
return when.reject(new RetryException('NoRetryStrategy: The operation has failed and the no-retry strategy refuses to retry it. Aborting.', error));
}
else{
return when.reject(error);
}
};
}
function validatePasswordLength(password) {
try {
if (!validator.isLength(password, 8)) {
throw new Error('Your password must be at least 8 characters long.');
}
} catch (error) {
return when.reject(error);
}
return when.resolve();
}
]).catch(function(err) {
if (self.options.protocol) {
alg = self.keyAlgorithmForProtocol(self.options.protocol);
return when.resolve();
}
return when.reject(err);
});
},