Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.route = function(req, res) {
var auth_token = req.param("token"),
auth_secret = req.param("secret"),
content = req.param("content"),
path = req.params[0];
//
path = path.replace(/\s$/, '');
//
console.log('');
console.log('');
console.log("request put: ", auth_token, auth_secret, path);
console.log("config: ", config);
console.log(content.length + " chars");
//
var dropbox = new DropboxClient(config.key, config.secret, auth_token, auth_secret);
dropbox.put(content || '', path, function() {
res.send("{response: 'ok'}");
});
};
exports.route = function(req, res) {
var auth_token = req.param("token"),
auth_secret = req.param("secret"),
path = req.params[0];
//
console.log('');
console.log('');
console.log("request list: ", auth_token, auth_secret, path);
console.log("config: ", config);
//console.log(req.params);
//
var dropbox = new DropboxClient(config.key, config.secret, auth_token, auth_secret);
//
list(dropbox, path, function(inErr, inResponse) {
console.log("response: ", inErr || inResponse);
res.send(inErr || inResponse);
});
};
exports.route = function(req, res) {
var auth_token = req.param("token"),
auth_secret = req.param("secret"),
path = req.params[0];
//
console.log('');
console.log('');
console.log("request get: ", auth_token, auth_secret, path);
console.log("config: ", config);
//console.log(req.params);
//
var dropbox = new DropboxClient(config.key, config.secret, auth_token, auth_secret);
//
var request = dropbox.getFileStream(path);
request.on('response', function(response) {
response.pipe(res);
});
request.on('error', function(response) {
response.send("error");
});
request.end();
};
lfs.readObjectFromFile('auth.json', function(auth) {
if(auth.token) dapp = new dbox(auth.key, auth.ksecret, auth.token, auth.tsecret);
app.listen(processInfo.port,function() {
var returnedInfo = {port: processInfo.port};
console.log(JSON.stringify(returnedInfo));
});
});
app.get('/init', function(req, res) {
if(!req.param('email') || !req.param('pass') || !req.param('key') || !req.param('secret') ) {
res.writeHead(400);
res.end('whats the creds yo?');
return;
}
console.log("initializing for "+req.param('email') );
dapp = new dbox(req.param('key'), req.param('secret'));
dapp.getAccessToken(req.param('email'), req.param('pass'), function(err, token, secret){
if(err)
{
res.writeHead(500);
res.end("failed: "+JSON.stringify(err));
return;
}
fs.writeFileSync('auth.json', JSON.stringify({key:req.param('key'), ksecret:req.param('secret'), token:token, tsecret:secret}));
res.writeHead(200, {'Content-Type': 'text/html'});
res.end("saved access token "+token+", <a href="./">continue</a>");
});
});
function connect(inUser, inPassword, next) {
new Dropbox(config.key, config.secret)
.getAccessToken(inUser, inPassword,
function(err, token, secret) {
next(err, {token: token, secret: secret});
}
);
}