mirror of
https://github.com/nextcloud/passman.git
synced 2025-10-06 03:34:54 +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){
|
} catch (DoesNotExistException $e){
|
||||||
return new NotFoundJSONResponse();
|
return new NotFoundJSONResponse();
|
||||||
}
|
}
|
||||||
|
$userId = ($this->userId) ? $this->userId->getUID() : null;
|
||||||
$acl = $this->shareService->getACL($this->userId->getUID(), $credential->getGuid());
|
$acl = $this->shareService->getACL($userId, $credential->getGuid());
|
||||||
if (!$acl->hasPermission(SharingACL::FILES)){
|
if (!$acl->hasPermission(SharingACL::FILES)){
|
||||||
return new NotFoundJSONResponse();
|
return new NotFoundJSONResponse();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -9,20 +9,18 @@
|
||||||
* Controller of the passmanApp
|
* Controller of the passmanApp
|
||||||
*/
|
*/
|
||||||
angular.module('passmanApp')
|
angular.module('passmanApp')
|
||||||
.controller('PublicSharedCredential', ['$scope', 'ShareService', '$window', function ($scope, ShareService, $window) {
|
.controller('PublicSharedCredential', ['$scope', 'ShareService', '$window', 'EncryptService', 'NotificationService', function ($scope, ShareService, $window, EncryptService, NotificationService) {
|
||||||
$scope.test = 'hello world';
|
var _key;
|
||||||
//@TODO Add download files
|
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
$scope.loadSharedCredential = function () {
|
$scope.loadSharedCredential = function () {
|
||||||
$scope.loading = true;
|
$scope.loading = true;
|
||||||
var data = window.atob($window.location.hash.replace('#', '')).split('<::>');
|
var data = window.atob($window.location.hash.replace('#', '')).split('<::>');
|
||||||
var guid = data[0];
|
var guid = data[0];
|
||||||
var _key = data[1];
|
_key = data[1];
|
||||||
ShareService.getPublicSharedCredential(guid).then(function (sharedCredential) {
|
ShareService.getPublicSharedCredential(guid).then(function (sharedCredential) {
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
if (sharedCredential.status === 200) {
|
if (sharedCredential.status === 200) {
|
||||||
var _credential = ShareService.decryptSharedCredential(sharedCredential.data.credential_data, _key);
|
$scope.shared_credential = ShareService.decryptSharedCredential(sharedCredential.data.credential_data, _key);
|
||||||
$scope.shared_credential = _credential;
|
|
||||||
} else {
|
} else {
|
||||||
$scope.expired = true;
|
$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/sha/sha');
|
||||||
script('passman', 'vendor/llqrcode/llqrcode');
|
script('passman', 'vendor/llqrcode/llqrcode');
|
||||||
script('passman', 'vendor/forge.0.6.9.min');
|
script('passman', 'vendor/forge.0.6.9.min');
|
||||||
|
script('passman', 'vendor/download');
|
||||||
script('passman', 'lib/promise');
|
script('passman', 'lib/promise');
|
||||||
script('passman', 'lib/crypto_wrap');
|
script('passman', 'lib/crypto_wrap');
|
||||||
|
|
||||||
|
@ -138,7 +139,7 @@ style('passman', 'public-page');
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div ng-repeat="file in shared_credential.files"
|
<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}})
|
{{file.filename}} ({{file.size | bytes}})
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|
Loading…
Add table
Reference in a new issue