diff --git a/src/js/dao/cloudstorage-dao.js b/src/js/dao/cloudstorage-dao.js index aa4d7fe..a265d31 100644 --- a/src/js/dao/cloudstorage-dao.js +++ b/src/js/dao/cloudstorage-dao.js @@ -24,7 +24,8 @@ define(['jquery', 'js/app-config'], function($, app) { }, error: function(xhr, textStatus, err) { callback({ - errMsg: xhr.status + ': ' + xhr.statusText, + code: xhr.status, + errMsg: xhr.statusText, err: err }); } @@ -45,7 +46,8 @@ define(['jquery', 'js/app-config'], function($, app) { }, error: function(xhr, textStatus, err) { callback({ - errMsg: xhr.status + ': ' + xhr.statusText, + code: xhr.status, + errMsg: xhr.statusText, err: err }); } @@ -64,7 +66,8 @@ define(['jquery', 'js/app-config'], function($, app) { }, error: function(xhr, textStatus, err) { callback({ - errMsg: xhr.status + ': ' + xhr.statusText, + code: xhr.status, + errMsg: xhr.statusText, err: err }); } @@ -146,6 +149,12 @@ define(['jquery', 'js/app-config'], function($, app) { var uri = app.config.cloudUrl + '/publickey/user/' + userId; self.get(uri, function(err, keys) { + // not found + if (err && err.code === 404) { + callback(); + return; + } + if (err) { callback(err); return; @@ -184,47 +193,5 @@ define(['jquery', 'js/app-config'], function($, app) { self.remove(uri, callback); }; - // - // Ecrypted Private Key - // - - /** - * Fetch private key by id - */ - self.getPrivateKey = function(keyId, callback) { - var uri = app.config.cloudUrl + '/privatekey/key/' + keyId; - self.get(uri, function(err, key) { - if (err) { - callback(err); - return; - } - - if (!key || !key._id) { - callback({ - errMsg: 'No private key for that user!' - }); - return; - } - - callback(null, key); - }); - }; - - /** - * Persist encrypted private key to cloud service - */ - self.putPrivateKey = function(privkey, callback) { - var uri = app.config.cloudUrl + '/privatekey/user/' + privkey.userId + '/key/' + privkey._id; - self.put(privkey, uri, callback); - }; - - /** - * Delete the private key from the cloud storage service - */ - self.removePrivateKey = function(keyId, callback) { - var uri = app.config.cloudUrl + '/privatekey/key/' + keyId; - self.remove(uri, callback); - }; - return self; }); \ No newline at end of file