diff --git a/src/services/apiService.js b/src/services/apiService.js index 9dca702f..c21ad0ad 100644 --- a/src/services/apiService.js +++ b/src/services/apiService.js @@ -339,6 +339,25 @@ function initApiService() { }); }; + ApiService.prototype.deleteFolder = function (id, success, error) { + var self = this; + handleTokenState(self).then(function (token) { + $.ajax({ + type: 'POST', + url: self.baseUrl + '/folders/' + id + '/delete?' + token, + dataType: 'text', + success: function (response) { + success(); + }, + error: function (jqXHR, textStatus, errorThrown) { + handleError(error, jqXHR, false, self); + } + }); + }, function (jqXHR) { + handleError(error, jqXHR, true, self); + }); + }; + // Cipher APIs ApiService.prototype.getCipher = function (id, success, error) { diff --git a/src/services/folderService.js b/src/services/folderService.js index 09e575d5..78717a76 100644 --- a/src/services/folderService.js +++ b/src/services/folderService.js @@ -18,7 +18,7 @@ function initFolderService() { id: folder.id }; - return self.cryptoService.encrypt(folder.name).then(function (cs) { + return this.cryptoService.encrypt(folder.name).then(function (cs) { model.name = cs; return model; }); @@ -206,6 +206,8 @@ function initFolderService() { var self = this; + // TODO: Delete folder reference for associated ciphers + self.userService.getUserId(function (userId) { var foldersKey = 'folders_' + userId; @@ -244,7 +246,7 @@ function initFolderService() { var deferred = Q.defer(); var self = this; - self.apiService.deleteCipher(id, function () { + self.apiService.deleteFolder(id, function () { self.delete(id, function () { deferred.resolve(); });