mirror of
https://github.com/nextcloud/passman.git
synced 2025-10-27 13:56:16 +08:00
Link sharing works
This commit is contained in:
parent
4ded0d8e0b
commit
294b9f7201
6 changed files with 21 additions and 81 deletions
|
|
@ -419,14 +419,14 @@
|
|||
<field>
|
||||
<name>vault_id</name>
|
||||
<type>integer</type>
|
||||
<notnull>true</notnull>
|
||||
<notnull>false</notnull>
|
||||
<unsigned>true</unsigned>
|
||||
<length>8</length>
|
||||
</field>
|
||||
<field>
|
||||
<name>vault_guid</name>
|
||||
<type>text</type>
|
||||
<notnull>true</notnull>
|
||||
<notnull>false</notnull>
|
||||
<length>64</length>
|
||||
</field>
|
||||
<field>
|
||||
|
|
@ -470,7 +470,7 @@
|
|||
<field>
|
||||
<name>shared_key</name>
|
||||
<type>clob</type>
|
||||
<notnull>true</notnull>
|
||||
<notnull>false</notnull>
|
||||
</field>
|
||||
</declaration>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<description>A password manager for Nextcloud</description>
|
||||
<licence>AGPL</licence>
|
||||
<author>Sander Brand</author>
|
||||
<version>1.0.2.21</version>
|
||||
<version>1.0.2.24</version>
|
||||
<namespace>Passman</namespace>
|
||||
<category>other</category>
|
||||
<website>https://github.com/nextcloud/passman/</website>
|
||||
|
|
|
|||
|
|
@ -297,6 +297,8 @@ class ShareController extends ApiController {
|
|||
* @PublicPage
|
||||
*/
|
||||
public function getPublicCredentialData($credential_guid) {
|
||||
//@TODO if ExpireViews --, if 0 delete
|
||||
//@TODO Check expire date
|
||||
try {
|
||||
$credential = $this->shareService->getSharedItem(null, $credential_guid);
|
||||
return new JSONResponse($credential);
|
||||
|
|
|
|||
|
|
@ -10,83 +10,20 @@ angular.module('passmanApp')
|
|||
$scope.test = 'hello world';
|
||||
|
||||
$scope.loading = false;
|
||||
|
||||
|
||||
var example_shared_credential = {
|
||||
"credential_id": 292,
|
||||
"guid": "3D18EAD3-CF40-4B2B-B568-82CD7CB3D47F",
|
||||
"user_id": "sander",
|
||||
"vault_id": 2,
|
||||
"label": "donnelly.com",
|
||||
"description": null,
|
||||
"created": 1475479693,
|
||||
"changed": 1475479693,
|
||||
"tags": [{"text": "Games"}],
|
||||
"email": null,
|
||||
"username": "ebrekke",
|
||||
"password": "hd%/U_%vzvh%",
|
||||
"url": "http://api.namefake.com/english-united-states/male/2854dda4938c9c5f60a288fa6fbe5095",
|
||||
"favicon": null,
|
||||
"renew_interval": null,
|
||||
"expire_time": 0,
|
||||
"delete_time": 0,
|
||||
"files": [{
|
||||
"file_id": 1,
|
||||
"filename": "20160925-Clipperz_Export.html",
|
||||
"guid": "6DA2CE41-A26B-4F97-A334-2CC74F7E9890",
|
||||
"size": 13863,
|
||||
"created": 1475485368,
|
||||
"mimetype": "text/html",
|
||||
"$$hashKey": "object:1261"
|
||||
}, {
|
||||
"file_id": 2,
|
||||
"filename": "20160925_Clipperz_Offline.html",
|
||||
"guid": "9337D189-B79E-4750-BEF9-3C912A9EA59D",
|
||||
"size": 3088428,
|
||||
"created": 1475485376,
|
||||
"mimetype": "text/html",
|
||||
"$$hashKey": "object:1268"
|
||||
}],
|
||||
"custom_fields": [{
|
||||
"label": "Test field",
|
||||
"value": "blah blah",
|
||||
"secret": false,
|
||||
"$$hashKey": "object:1205"
|
||||
}, {
|
||||
"label": "another field =)",
|
||||
"value": "vlaue",
|
||||
"secret": true,
|
||||
"$$hashKey": "object:1220"
|
||||
}],
|
||||
"otp": {
|
||||
"type": "totp",
|
||||
"label": "Google:fake@gmail.com",
|
||||
"qr_uri": {
|
||||
"qrData": "otpauth://totp/Google%3Afake%40gmail.com?secret=oyonyttithtryvpnqqrxluytgwon2mhw&issuer=Google",
|
||||
"image": ""
|
||||
},
|
||||
"secret": "oyonyttithtryvpnqqrxluytgwon2mhw",
|
||||
"issuer": "Google"
|
||||
},
|
||||
"hidden": 0,
|
||||
"shared_key": null,
|
||||
"tags_raw": [{"text": "Games"}]
|
||||
};
|
||||
|
||||
$scope.loadSharedCredential = function () {
|
||||
$scope.loading = true;
|
||||
var guid = $window.location.hash.replace('#','');
|
||||
var data = window.atob($window.location.hash.replace('#','')).split('<::>');
|
||||
var guid = data[0];
|
||||
var _key = data[1];
|
||||
ShareService.getPublicSharedCredential(guid).then(function (sharedCredential) {
|
||||
$scope.loading = false;
|
||||
console.log(sharedCredential)
|
||||
if(sharedCredential.status === 200){
|
||||
$scope.shared_credential = example_shared_credential;
|
||||
var _credential = ShareService.decryptSharedCredential(sharedCredential.data.credential_data, _key);
|
||||
$scope.shared_credential = _credential;
|
||||
} else {
|
||||
$scope.expired = true;
|
||||
}
|
||||
|
||||
}, function(error){
|
||||
return false;
|
||||
})
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,6 @@ angular.module('passmanApp')
|
|||
$location.path('/vault/' + $scope.storedCredential.vault_id);
|
||||
};
|
||||
|
||||
$scope.share_link = $location.$$protocol + '://' + $location.$$host + OC.generateUrl('apps/passman/share/public#') + $scope.storedCredential.guid;
|
||||
|
||||
$scope.default_permissions = new SharingACL(0);
|
||||
$scope.default_permissions.addPermission(
|
||||
|
|
@ -138,13 +137,12 @@ angular.module('passmanApp')
|
|||
};
|
||||
|
||||
$scope.unshareCredential = function (credential) {
|
||||
ShareService.unshareCredential(credential).then(function () {
|
||||
ShareService.unshareCredential(credential);
|
||||
var _credential = angular.copy(credential);
|
||||
_credential.shared_key = null;
|
||||
CredentialService.updateCredential(_credential).then(function () {
|
||||
NotificationService.showNotification('Credential unshared', 4000)
|
||||
})
|
||||
})
|
||||
};
|
||||
|
||||
$scope.applyShare = function () {
|
||||
|
|
@ -196,12 +194,15 @@ angular.module('passmanApp')
|
|||
|
||||
if($scope.share_settings.linkSharing.enabled){
|
||||
var shareObj = {
|
||||
item_id: '',
|
||||
item_id: $scope.storedCredential.credential_id,
|
||||
item_guid: $scope.storedCredential.guid,
|
||||
permissions: $scope.share_settings.linkSharing.settings.acl.getAccessLevel(),
|
||||
expire_timestamp: $scope.share_settings.linkSharing.settings.expire_time,
|
||||
expire_views: $scope.share_settings.linkSharing.settings.expire_views
|
||||
};
|
||||
ShareService.createPublicSharedCredential(shareObj).then(function(){
|
||||
var hash = window.btoa($scope.storedCredential.guid + '<::>'+ key)
|
||||
$scope.share_link = $location.$$protocol + '://' + $location.$$host + OC.generateUrl('apps/passman/share/public#') + hash;
|
||||
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ style('passman', 'public-page');
|
|||
<div class="col-xs-8 col-xs-push-2 col-xs-pull-2 credential_container">
|
||||
<h2>Passman</h2>
|
||||
<div ng-if="!shared_credential && !expired">
|
||||
<span class="text">{name} has shared a credential with you.</span>
|
||||
<span class="text">Someone has shared a credential with you.</span>
|
||||
<button class="button-geen" ng-if="!loading"
|
||||
ng-click="loadSharedCredential()">Click here to request
|
||||
it
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue