mirror of
https://github.com/nextcloud/passman.git
synced 2025-10-04 02:34:29 +08:00
Download files from link shared credential
Add missing ;
This commit is contained in:
parent
82314fadc3
commit
0d7cf6e055
3 changed files with 20 additions and 9 deletions
|
@ -469,8 +469,8 @@ class ShareController extends ApiController {
|
|||
} catch (DoesNotExistException $e){
|
||||
return new NotFoundJSONResponse();
|
||||
}
|
||||
|
||||
$acl = $this->shareService->getACL($this->userId->getUID(), $credential->getGuid());
|
||||
$userId = ($this->userId) ? $this->userId->getUID() : null;
|
||||
$acl = $this->shareService->getACL($userId, $credential->getGuid());
|
||||
if (!$acl->hasPermission(SharingACL::FILES)){
|
||||
return new NotFoundJSONResponse();
|
||||
} else {
|
||||
|
|
|
@ -9,20 +9,18 @@
|
|||
* Controller of the passmanApp
|
||||
*/
|
||||
angular.module('passmanApp')
|
||||
.controller('PublicSharedCredential', ['$scope', 'ShareService', '$window', function ($scope, ShareService, $window) {
|
||||
$scope.test = 'hello world';
|
||||
//@TODO Add download files
|
||||
.controller('PublicSharedCredential', ['$scope', 'ShareService', '$window', 'EncryptService', 'NotificationService', function ($scope, ShareService, $window, EncryptService, NotificationService) {
|
||||
var _key;
|
||||
$scope.loading = false;
|
||||
$scope.loadSharedCredential = function () {
|
||||
$scope.loading = true;
|
||||
var data = window.atob($window.location.hash.replace('#', '')).split('<::>');
|
||||
var guid = data[0];
|
||||
var _key = data[1];
|
||||
_key = data[1];
|
||||
ShareService.getPublicSharedCredential(guid).then(function (sharedCredential) {
|
||||
$scope.loading = false;
|
||||
if (sharedCredential.status === 200) {
|
||||
var _credential = ShareService.decryptSharedCredential(sharedCredential.data.credential_data, _key);
|
||||
$scope.shared_credential = _credential;
|
||||
$scope.shared_credential = ShareService.decryptSharedCredential(sharedCredential.data.credential_data, _key);
|
||||
} else {
|
||||
$scope.expired = true;
|
||||
}
|
||||
|
@ -30,5 +28,17 @@
|
|||
});
|
||||
|
||||
};
|
||||
|
||||
$scope.downloadFile = function (credential, file) {
|
||||
ShareService.downloadSharedFile(credential, file).then(function (result) {
|
||||
var key = null;
|
||||
if (!result.hasOwnProperty('file_data')) {
|
||||
NotificationService.showNotification('Error downloading file, you probably don\'t have enough permissions', 5000);
|
||||
return;
|
||||
}
|
||||
var file_data = EncryptService.decryptString(result.file_data, _key);
|
||||
download(file_data, escapeHTML(file.filename), file.mimetype);
|
||||
});
|
||||
};
|
||||
}]);
|
||||
}());
|
||||
|
|
|
@ -22,6 +22,7 @@ script('passman', 'vendor/angular-xeditable/xeditable.min');
|
|||
script('passman', 'vendor/sha/sha');
|
||||
script('passman', 'vendor/llqrcode/llqrcode');
|
||||
script('passman', 'vendor/forge.0.6.9.min');
|
||||
script('passman', 'vendor/download');
|
||||
script('passman', 'lib/promise');
|
||||
script('passman', 'lib/crypto_wrap');
|
||||
|
||||
|
@ -138,7 +139,7 @@ style('passman', 'public-page');
|
|||
</td>
|
||||
<td>
|
||||
<div ng-repeat="file in shared_credential.files"
|
||||
class="link" ng-click="downloadFile(file)">
|
||||
class="link" ng-click="downloadFile(shared_credential, file)">
|
||||
{{file.filename}} ({{file.size | bytes}})
|
||||
</div>
|
||||
</td>
|
||||
|
|
Loading…
Add table
Reference in a new issue