| Conditions | 1 |
| Paths | 1 |
| Total Lines | 31 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | (function () { |
||
| 12 | .controller('PublicSharedCredential', ['$scope', 'ShareService', '$window', 'EncryptService', 'NotificationService', function ($scope, ShareService, $window, EncryptService, NotificationService) { |
||
| 13 | var _key; |
||
| 14 | $scope.loading = false; |
||
| 15 | $scope.loadSharedCredential = function () { |
||
| 16 | $scope.loading = true; |
||
| 17 | var data = window.atob($window.location.hash.replace('#', '')).split('<::>'); |
||
| 18 | var guid = data[0]; |
||
| 19 | _key = data[1]; |
||
| 20 | ShareService.getPublicSharedCredential(guid).then(function (sharedCredential) { |
||
| 21 | $scope.loading = false; |
||
| 22 | if (sharedCredential.status === 200) { |
||
| 23 | $scope.shared_credential = ShareService.decryptSharedCredential(sharedCredential.data.credential_data, _key); |
||
| 24 | } else { |
||
| 25 | $scope.expired = true; |
||
| 26 | } |
||
| 27 | |||
| 28 | }); |
||
| 29 | |||
| 30 | }; |
||
| 31 | |||
| 32 | $scope.downloadFile = function (credential, file) { |
||
| 33 | ShareService.downloadSharedFile(credential, file).then(function (result) { |
||
| 34 | if (!result.hasOwnProperty('file_data')) { |
||
| 35 | NotificationService.showNotification('Error downloading file, you probably don\'t have enough permissions', 5000); |
||
| 36 | return; |
||
| 37 | } |
||
| 38 | var file_data = EncryptService.decryptString(result.file_data, _key); |
||
| 39 | download(file_data, escapeHTML(file.filename), file.mimetype); |
||
| 40 | }); |
||
| 41 | }; |
||
| 42 | }]); |
||
| 43 | }()); |
||
| 44 |