reformat according to jshint
This commit is contained in:
parent
51c4b83a3c
commit
37248a2c27
@ -92,14 +92,11 @@ emailPlugin.init = function (config) {
|
|||||||
emailPlugin.crypto = config.crypto || crypto;
|
emailPlugin.crypto = config.crypto || crypto;
|
||||||
|
|
||||||
emailPlugin.confirmUrl = (
|
emailPlugin.confirmUrl = (
|
||||||
process.env.INSIGHT_EMAIL_CONFIRM_HOST
|
process.env.INSIGHT_EMAIL_CONFIRM_HOST || config.confirmUrl || 'https://insight.bitpay.com'
|
||||||
|| config.confirmUrl
|
|
||||||
|| 'https://insight.bitpay.com'
|
|
||||||
) + globalConfig.apiPrefix + '/email/validate';
|
) + globalConfig.apiPrefix + '/email/validate';
|
||||||
|
|
||||||
emailPlugin.redirectUrl = (
|
emailPlugin.redirectUrl = (
|
||||||
config.redirectUrl
|
config.redirectUrl || 'https://copay.io/in/app?confirmed=true'
|
||||||
|| 'https://copay.io/in/app?confirmed=true'
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -115,7 +112,9 @@ emailPlugin.init = function (config) {
|
|||||||
* will be called, terminating the request.
|
* will be called, terminating the request.
|
||||||
*/
|
*/
|
||||||
emailPlugin.returnError = function(error, response) {
|
emailPlugin.returnError = function(error, response) {
|
||||||
response.status(error.code).json({error: error.message}).end();
|
response.status(error.code).json({
|
||||||
|
error: error.message
|
||||||
|
}).end();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -127,6 +126,7 @@ emailPlugin.returnError = function (error, response) {
|
|||||||
emailPlugin.sendVerificationEmail = function(email, secret) {
|
emailPlugin.sendVerificationEmail = function(email, secret) {
|
||||||
var confirmUrl = emailPlugin.makeConfirmUrl(email, secret);
|
var confirmUrl = emailPlugin.makeConfirmUrl(email, secret);
|
||||||
async.series([
|
async.series([
|
||||||
|
|
||||||
function(callback) {
|
function(callback) {
|
||||||
emailPlugin.makeEmailBody({
|
emailPlugin.makeEmailBody({
|
||||||
email: email,
|
email: email,
|
||||||
@ -340,7 +340,9 @@ emailPlugin.save = function (request, response) {
|
|||||||
queryData += data;
|
queryData += data;
|
||||||
if (queryData.length > MAX_ALLOWED_STORAGE) {
|
if (queryData.length > MAX_ALLOWED_STORAGE) {
|
||||||
queryData = '';
|
queryData = '';
|
||||||
response.writeHead(413, {'Content-Type': 'text/plain'}).end();
|
response.writeHead(413, {
|
||||||
|
'Content-Type': 'text/plain'
|
||||||
|
}).end();
|
||||||
request.connection.destroy();
|
request.connection.destroy();
|
||||||
}
|
}
|
||||||
}).on('end', function() {
|
}).on('end', function() {
|
||||||
@ -402,7 +404,10 @@ emailPlugin.processPost = function(request, response, email, key, passphrase, re
|
|||||||
function(callback) {
|
function(callback) {
|
||||||
emailPlugin.createVerificationSecretAndSendEmail(email, function(err) {
|
emailPlugin.createVerificationSecretAndSendEmail(email, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
callback({code: 500, message: err});
|
callback({
|
||||||
|
code: 500,
|
||||||
|
message: err
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
@ -412,10 +417,11 @@ emailPlugin.processPost = function(request, response, email, key, passphrase, re
|
|||||||
if (err) {
|
if (err) {
|
||||||
emailPlugin.returnError(err, response);
|
emailPlugin.returnError(err, response);
|
||||||
} else {
|
} else {
|
||||||
response.json({success: true}).end();
|
response.json({
|
||||||
|
success: true
|
||||||
|
}).end();
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -431,7 +437,10 @@ emailPlugin.getCredentialsFromRequest = function(request) {
|
|||||||
var email = authHeader.substr(0, splitIndex);
|
var email = authHeader.substr(0, splitIndex);
|
||||||
var passphrase = authHeader.substr(splitIndex + 1);
|
var passphrase = authHeader.substr(splitIndex + 1);
|
||||||
|
|
||||||
return {email: email, passphrase: passphrase};
|
return {
|
||||||
|
email: email,
|
||||||
|
passphrase: passphrase
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -480,17 +489,26 @@ emailPlugin.validate = function (request, response) {
|
|||||||
if (err.notFound) {
|
if (err.notFound) {
|
||||||
return emailPlugin.returnError(emailPlugin.errors.NOT_FOUND, response);
|
return emailPlugin.returnError(emailPlugin.errors.NOT_FOUND, response);
|
||||||
}
|
}
|
||||||
return emailPlugin.returnError({code: 500, message: err}, response);
|
return emailPlugin.returnError({
|
||||||
|
code: 500,
|
||||||
|
message: err
|
||||||
|
}, response);
|
||||||
} else if (value !== secret) {
|
} else if (value !== secret) {
|
||||||
return emailPlugin.returnError(emailPlugin.errors.INVALID_CODE, response);
|
return emailPlugin.returnError(emailPlugin.errors.INVALID_CODE, response);
|
||||||
} else {
|
} else {
|
||||||
emailPlugin.db.put(validatedKey(email), true, function(err, value) {
|
emailPlugin.db.put(validatedKey(email), true, function(err, value) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return emailPlugin.returnError({code: 500, message: err}, response);
|
return emailPlugin.returnError({
|
||||||
|
code: 500,
|
||||||
|
message: err
|
||||||
|
}, response);
|
||||||
} else {
|
} else {
|
||||||
emailPlugin.db.del(pendingKey(email), function(err, value) {
|
emailPlugin.db.del(pendingKey(email), function(err, value) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return emailPlugin.returnError({code: 500, message: err}, response);
|
return emailPlugin.returnError({
|
||||||
|
code: 500,
|
||||||
|
message: err
|
||||||
|
}, response);
|
||||||
} else {
|
} else {
|
||||||
response.redirect(emailPlugin.redirectUrl);
|
response.redirect(emailPlugin.redirectUrl);
|
||||||
}
|
}
|
||||||
@ -520,7 +538,9 @@ emailPlugin.changePassphrase = function (request, response) {
|
|||||||
queryData += data;
|
queryData += data;
|
||||||
if (queryData.length > MAX_ALLOWED_STORAGE) {
|
if (queryData.length > MAX_ALLOWED_STORAGE) {
|
||||||
queryData = '';
|
queryData = '';
|
||||||
response.writeHead(413, {'Content-Type': 'text/plain'}).end();
|
response.writeHead(413, {
|
||||||
|
'Content-Type': 'text/plain'
|
||||||
|
}).end();
|
||||||
request.connection.destroy();
|
request.connection.destroy();
|
||||||
}
|
}
|
||||||
}).on('end', function() {
|
}).on('end', function() {
|
||||||
@ -537,7 +557,9 @@ emailPlugin.changePassphrase = function (request, response) {
|
|||||||
if (error) {
|
if (error) {
|
||||||
return emailPlugin.returnError(error, response);
|
return emailPlugin.returnError(error, response);
|
||||||
}
|
}
|
||||||
return response.json({success: true}).end();
|
return response.json({
|
||||||
|
success: true
|
||||||
|
}).end();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -569,7 +591,9 @@ emailPlugin.oldSave = function (request, response) {
|
|||||||
queryData += data;
|
queryData += data;
|
||||||
if (queryData.length > MAX_ALLOWED_STORAGE) {
|
if (queryData.length > MAX_ALLOWED_STORAGE) {
|
||||||
queryData = '';
|
queryData = '';
|
||||||
response.writeHead(413, {'Content-Type': 'text/plain'}).end();
|
response.writeHead(413, {
|
||||||
|
'Content-Type': 'text/plain'
|
||||||
|
}).end();
|
||||||
request.connection.destroy();
|
request.connection.destroy();
|
||||||
}
|
}
|
||||||
}).on('end', function() {
|
}).on('end', function() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user