mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-29 17:38:04 +01:00
toasts and error handling
This commit is contained in:
parent
51e30b2f7a
commit
25536e10ef
@ -2,7 +2,7 @@
|
|||||||
.module('bit.vault')
|
.module('bit.vault')
|
||||||
|
|
||||||
.controller('vaultShareLoginController', function ($scope, apiService, $uibModalInstance, authService, cipherService,
|
.controller('vaultShareLoginController', function ($scope, apiService, $uibModalInstance, authService, cipherService,
|
||||||
loginId, $analytics, $state, cryptoService, $q) {
|
loginId, $analytics, $state, cryptoService, $q, toastr) {
|
||||||
$analytics.eventTrack('vaultShareLoginController', { category: 'Modal' });
|
$analytics.eventTrack('vaultShareLoginController', { category: 'Modal' });
|
||||||
$scope.model = {};
|
$scope.model = {};
|
||||||
$scope.login = {};
|
$scope.login = {};
|
||||||
@ -113,6 +113,7 @@
|
|||||||
$scope.submit = function (model) {
|
$scope.submit = function (model) {
|
||||||
var orgKey = cryptoService.getOrgKey(model.organizationId);
|
var orgKey = cryptoService.getOrgKey(model.organizationId);
|
||||||
|
|
||||||
|
var errorOnUpload = false;
|
||||||
var attachmentSharePromises = [];
|
var attachmentSharePromises = [];
|
||||||
if ($scope.login.attachments) {
|
if ($scope.login.attachments) {
|
||||||
for (var i = 0; i < $scope.login.attachments.length; i++) {
|
for (var i = 0; i < $scope.login.attachments.length; i++) {
|
||||||
@ -121,6 +122,10 @@
|
|||||||
.then(function (decData) {
|
.then(function (decData) {
|
||||||
return cryptoService.encryptToBytes(decData.buffer, orgKey);
|
return cryptoService.encryptToBytes(decData.buffer, orgKey);
|
||||||
}).then(function (encData) {
|
}).then(function (encData) {
|
||||||
|
if (errorOnUpload) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var fd = new FormData();
|
var fd = new FormData();
|
||||||
var blob = new Blob([encData], { type: 'application/octet-stream' });
|
var blob = new Blob([encData], { type: 'application/octet-stream' });
|
||||||
var encFilename = cryptoService.encrypt(attachment.fileName, orgKey);
|
var encFilename = cryptoService.encrypt(attachment.fileName, orgKey);
|
||||||
@ -131,6 +136,8 @@
|
|||||||
attachmentId: attachment.id,
|
attachmentId: attachment.id,
|
||||||
orgId: model.organizationId
|
orgId: model.organizationId
|
||||||
}, fd).$promise;
|
}, fd).$promise;
|
||||||
|
}, function (err) {
|
||||||
|
errorOnUpload = true;
|
||||||
});
|
});
|
||||||
attachmentSharePromises.push(promise);
|
attachmentSharePromises.push(promise);
|
||||||
})($scope.login.attachments[i]);
|
})($scope.login.attachments[i]);
|
||||||
@ -138,6 +145,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$scope.submitPromise = $q.all(attachmentSharePromises).then(function () {
|
$scope.submitPromise = $q.all(attachmentSharePromises).then(function () {
|
||||||
|
if (errorOnUpload) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$scope.login.organizationId = model.organizationId;
|
$scope.login.organizationId = model.organizationId;
|
||||||
|
|
||||||
var request = {
|
var request = {
|
||||||
@ -154,6 +165,7 @@
|
|||||||
return apiService.ciphers.putShare({ id: loginId }, request).$promise;
|
return apiService.ciphers.putShare({ id: loginId }, request).$promise;
|
||||||
}).then(function (response) {
|
}).then(function (response) {
|
||||||
$analytics.eventTrack('Shared Login');
|
$analytics.eventTrack('Shared Login');
|
||||||
|
toastr.success('Login has been shared.');
|
||||||
$uibModalInstance.close(model.organizationId);
|
$uibModalInstance.close(model.organizationId);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user