Permalink
Browse files

Fixed API endpoints in remote.

  • Loading branch information...
1 parent 6d0c831 commit ca1d6aefff75da2178016bcae0d52e01ddce46fd @tomas tomas committed Mar 6, 2013
Showing with 12 additions and 11 deletions.
  1. +12 −11 lib/conf/remote.js
View
@@ -8,8 +8,9 @@ var common = require('./../common'),
var base_opts = { follow: false, user_agent: user_agent };
-var get_host = function(){
- return config.get('host');
+var get_root = function(){
+ var host = config.get('host');
+ return host && config.get('protocol') + '://' + host + '/api/v2';
}
var log = function(str){
@@ -19,10 +20,10 @@ var log = function(str){
exports.authorize = function(args, cb){
log('Authenticating...');
- var host = get_host();
- if (!host) return cb(new Error('Control Panel host not set!'));
+ var root = get_root();
+ if (!root) return cb(new Error('Control Panel host not set!'));
- var url = 'https://' + host + '/profile.xml',
+ var url = root + '/profile.xml',
opts = base_opts;
// opts.parse = false;
@@ -49,11 +50,11 @@ exports.verify = function(args, cb){
if (!args.api_key || !args.device_key)
return cb(new Error('Both API and Device keys are needed.'));
- var host = get_host();
- if (!host) return cb(new Error('Control Panel host not set!'));
+ var root = get_root();
+ if (!root) return cb(new Error('Control Panel host not set!'));
log('Verifying keys...');
- var url = 'http://' + host + '/devices/' + args.device_key + '.xml',
+ var url = root + '/devices/' + args.device_key + '.xml',
opts = base_opts;
opts.username = args.api_key;
@@ -76,11 +77,11 @@ exports.verify = function(args, cb){
}
exports.signup = function(args, cb){
- var host = get_host();
- if (!host) return cb(new Error('Control Panel host not set!'))
+ var root = get_root();
+ if (!root) return cb(new Error('Control Panel host not set!'))
log('Signing you up...');
- var url = 'https://' + host + '/signup.xml';
+ var url = root + '/signup.xml';
http_client.post(url, args, base_opts, function(err, resp, body){
if (err) return callback(err);

0 comments on commit ca1d6ae

Please sign in to comment.