mirror of
https://github.com/nextcloud/passman.git
synced 2024-12-29 11:32:47 +08:00
Merge branch 'sharing_no_groups' of github.com:nextcloud/passman into sharing_no_groups
This commit is contained in:
commit
de0b08f91a
5 changed files with 50 additions and 26 deletions
|
@ -93,7 +93,7 @@ class CredentialController extends ApiController {
|
|||
$credential_id, $custom_fields, $delete_time,
|
||||
$description, $email, $expire_time, $favicon, $files, $guid,
|
||||
$hidden, $label, $otp, $password, $renew_interval,
|
||||
$tags, $url, $username, $vault_id, $revision_created, $shared_key) {
|
||||
$tags, $url, $username, $vault_id, $revision_created, $shared_key, $acl) {
|
||||
$credential = array(
|
||||
'credential_id' => $credential_id,
|
||||
'guid' => $guid,
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
*/
|
||||
angular.module('passmanApp')
|
||||
.controller('CredentialCtrl', ['$scope', 'VaultService', 'SettingsService', '$location', 'CredentialService',
|
||||
'$rootScope', 'FileService', 'EncryptService', 'TagService', '$timeout', 'NotificationService', 'CacheService', 'ShareService',
|
||||
function ($scope, VaultService, SettingsService, $location, CredentialService, $rootScope, FileService, EncryptService, TagService, $timeout, NotificationService, CacheService, ShareService) {
|
||||
'$rootScope', 'FileService', 'EncryptService', 'TagService', '$timeout', 'NotificationService', 'CacheService', 'ShareService', 'SharingACL',
|
||||
function ($scope, VaultService, SettingsService, $location, CredentialService, $rootScope, FileService, EncryptService, TagService, $timeout, NotificationService, CacheService, ShareService, SharingACL) {
|
||||
$scope.active_vault = VaultService.getActiveVault();
|
||||
if (!SettingsService.getSetting('defaultVault') || !SettingsService.getSetting('defaultVaultPass')) {
|
||||
if (!$scope.active_vault) {
|
||||
|
@ -32,6 +32,7 @@ angular.module('passmanApp')
|
|||
|
||||
var getSharedCredentials = function() {
|
||||
ShareService.getCredendialsSharedWithUs($scope.active_vault.guid).then(function (shared_credentials) {
|
||||
console.log('Shared credentials', shared_credentials);
|
||||
for (var c = 0; c < shared_credentials.length; c++) {
|
||||
var _shared_credential = shared_credentials[c];
|
||||
var decrypted_key = EncryptService.decryptString(_shared_credential.shared_key);
|
||||
|
@ -43,6 +44,7 @@ angular.module('passmanApp')
|
|||
if(_shared_credential_data){
|
||||
delete _shared_credential.credential_data;
|
||||
_shared_credential_data.acl = _shared_credential;
|
||||
_shared_credential_data.acl.permissions = new SharingACL(_shared_credential_data.acl.permissions);
|
||||
_shared_credential_data.tags_raw = _shared_credential_data.tags;
|
||||
console.log(_shared_credential_data)
|
||||
$scope.active_vault.credentials.push(_shared_credential_data);
|
||||
|
@ -99,6 +101,17 @@ angular.module('passmanApp')
|
|||
});
|
||||
}
|
||||
});
|
||||
|
||||
$scope.permissions = new SharingACL(0);
|
||||
|
||||
$scope.hasPermission = function(acl, permission){
|
||||
if(acl) {
|
||||
return acl.hasPermission(permission);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$scope.acceptShareRequest = function(share_request){
|
||||
console.log('Accepted share request', share_request);
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
* Controller of the passmanApp
|
||||
*/
|
||||
angular.module('passmanApp')
|
||||
.controller('CredentialEditCtrl', ['$scope', 'VaultService', 'CredentialService', 'SettingsService', '$location', '$routeParams', 'FileService', 'EncryptService', 'TagService', 'NotificationService',
|
||||
function ($scope, VaultService, CredentialService, SettingsService, $location, $routeParams, FileService, EncryptService, TagService, NotificationService) {
|
||||
.controller('CredentialEditCtrl', ['$scope', 'VaultService', 'CredentialService', 'SettingsService', '$location', '$routeParams', 'FileService', 'EncryptService', 'TagService', 'NotificationService', 'ShareService',
|
||||
function ($scope, VaultService, CredentialService, SettingsService, $location, $routeParams, FileService, EncryptService, TagService, NotificationService, ShareService) {
|
||||
$scope.active_vault = VaultService.getActiveVault();
|
||||
if (!SettingsService.getSetting('defaultVault') || !SettingsService.getSetting('defaultVaultPass')) {
|
||||
if (!$scope.active_vault) {
|
||||
|
@ -62,7 +62,6 @@ angular.module('passmanApp')
|
|||
}];
|
||||
|
||||
|
||||
|
||||
if (!SettingsService.getSetting('defaultVault') || !SettingsService.getSetting('defaultVaultPass')) {
|
||||
if (!$scope.active_vault) {
|
||||
$location.path('/')
|
||||
|
@ -82,7 +81,7 @@ angular.module('passmanApp')
|
|||
var storedCredential = SettingsService.getSetting('edit_credential');
|
||||
|
||||
if (!storedCredential) {
|
||||
CredentialService.getCredential($routeParams.credential_id).then(function(result){
|
||||
CredentialService.getCredential($routeParams.credential_id).then(function (result) {
|
||||
$scope.storedCredential = CredentialService.decryptCredential(angular.copy(result));
|
||||
});
|
||||
} else {
|
||||
|
@ -188,10 +187,10 @@ angular.module('passmanApp')
|
|||
$scope.renewIntervalValue = 0;
|
||||
$scope.renewIntervalModifier = '0';
|
||||
|
||||
$scope.updateInterval = function(renewIntervalValue, renewIntervalModifier){
|
||||
$scope.updateInterval = function (renewIntervalValue, renewIntervalModifier) {
|
||||
var value = parseInt(renewIntervalValue);
|
||||
var modifier = parseInt(renewIntervalModifier);
|
||||
if( value && modifier) {
|
||||
if (value && modifier) {
|
||||
$scope.storedCredential.renew_interval = value * modifier;
|
||||
}
|
||||
};
|
||||
|
@ -214,21 +213,34 @@ angular.module('passmanApp')
|
|||
$scope.saveCredential = function () {
|
||||
//@TODO validation
|
||||
//@TODO When credential is expired and has renew interval set, calc new expire time.
|
||||
console.log(JSON.stringify($scope.storedCredential));
|
||||
delete $scope.storedCredential.password_repeat;
|
||||
if (!$scope.storedCredential.credential_id) {
|
||||
$scope.storedCredential.vault_id = $scope.active_vault.vault_id;
|
||||
CredentialService.createCredential($scope.storedCredential).then(function (result) {
|
||||
$location.path('/vault/' + $routeParams.vault_id);
|
||||
NotificationService.showNotification('Credential created!', 5000)
|
||||
})
|
||||
} else {
|
||||
CredentialService.updateCredential($scope.storedCredential).then(function (result) {
|
||||
|
||||
if ($scope.storedCredential.hasOwnProperty('acl')) {
|
||||
var enc_key = EncryptService.decryptString(angular.copy($scope.storedCredential.acl.shared_key));
|
||||
console.log(enc_key)
|
||||
var _credential = ShareService.encryptSharedCredential($scope.storedCredential, enc_key);
|
||||
console.log(_credential);
|
||||
CredentialService.updateCredential(_credential).then(function (result) {
|
||||
SettingsService.setSetting('edit_credential', null);
|
||||
$location.path('/vault/' + $routeParams.vault_id);
|
||||
NotificationService.showNotification('Credential updated!', 5000)
|
||||
})
|
||||
} else {
|
||||
if (!$scope.storedCredential.credential_id) {
|
||||
$scope.storedCredential.vault_id = $scope.active_vault.vault_id;
|
||||
CredentialService.createCredential($scope.storedCredential).then(function (result) {
|
||||
$location.path('/vault/' + $routeParams.vault_id);
|
||||
NotificationService.showNotification('Credential created!', 5000)
|
||||
})
|
||||
} else {
|
||||
CredentialService.updateCredential($scope.storedCredential).then(function (result) {
|
||||
SettingsService.setSetting('edit_credential', null);
|
||||
$location.path('/vault/' + $routeParams.vault_id);
|
||||
NotificationService.showNotification('Credential updated!', 5000)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$scope.cancel = function () {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -213,32 +213,32 @@
|
|||
</div>
|
||||
|
||||
<div ng-show="selectedCredential">
|
||||
<div ng-if="!selectedCredential.acl || selectedCredential.acl.permissions == 2">
|
||||
<div>
|
||||
<button class="button"
|
||||
ng-click="editCredential(selectedCredential)"
|
||||
ng-if="selectedCredential.delete_time == 0">
|
||||
ng-if="selectedCredential.delete_time == 0 && hasPermission(selectedCredential.acl.permissions, permissions.permissions.WRITE)">
|
||||
<span class="fa fa-edit"></span> Edit
|
||||
</button>
|
||||
<button class="button"
|
||||
ng-click="deleteCredential(selectedCredential)"
|
||||
ng-if="selectedCredential.delete_time == 0">
|
||||
ng-if="selectedCredential.delete_time == 0 && hasPermission(selectedCredential.acl.permissions, permissions.permissions.WRITE)">
|
||||
<span class="fa fa-trash"></span> Delete
|
||||
</button>
|
||||
<button class="button"
|
||||
ng-click="shareCredential(selectedCredential)"
|
||||
ng-if="selectedCredential.delete_time == 0">
|
||||
ng-if="selectedCredential.delete_time == 0 && selectedCredential.acl === undefined">
|
||||
<span class="fa fa-share"></span> Share
|
||||
</button>
|
||||
|
||||
<button class="button"
|
||||
ng-click="getRevisions(selectedCredential)"
|
||||
ng-if="selectedCredential.delete_time == 0">
|
||||
ng-if="selectedCredential.delete_time == 0 && hasPermission(selectedCredential.acl.permissions, permissions.permissions.HISTORY)">
|
||||
<span class="fa fa-undo"></span> Revisions
|
||||
</button>
|
||||
|
||||
<button class="button"
|
||||
ng-if="selectedCredential.delete_time > 0"
|
||||
ng-click="recoverCredential(selectedCredential)">
|
||||
ng-click="recoverCredential(selectedCredential) && hasPermission(selectedCredential.acl.permissions, permissions.permissions.WRITE)">
|
||||
<span class="fa fa-recycle"></span> Recover
|
||||
</button>
|
||||
<button class="button"
|
||||
|
@ -247,7 +247,6 @@
|
|||
<span class="fa fa-bomb"></span> Destroy
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue