From 3355db8d89a91a293e52bf03a52886d209a222b9 Mon Sep 17 00:00:00 2001 From: brantje Date: Mon, 3 Oct 2016 17:23:03 +0200 Subject: [PATCH] Unshare credentials --- controller/credentialcontroller.php | 2 +- js/app/controllers/share.js | 13 +++++++++++-- js/templates.js | 2 +- templates/views/share_credential.html | 1 + 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/controller/credentialcontroller.php b/controller/credentialcontroller.php index 435e58b2..9e376b78 100644 --- a/controller/credentialcontroller.php +++ b/controller/credentialcontroller.php @@ -116,7 +116,7 @@ class CredentialController extends ApiController { 'delete_time' => $delete_time, 'hidden' => $hidden, 'otp' => $otp, - 'shared_key' => $shared_key, + 'shared_key' => ($shared_key) ? $shared_key : null, ); diff --git a/js/app/controllers/share.js b/js/app/controllers/share.js index bc0aec32..c79eea5d 100644 --- a/js/app/controllers/share.js +++ b/js/app/controllers/share.js @@ -9,7 +9,7 @@ * This file is part of passman, licensed under AGPLv3 */ angular.module('passmanApp') - .controller('ShareCtrl', ['$scope', 'VaultService', 'CredentialService', 'SettingsService', '$location', '$routeParams', 'ShareService', function ($scope, VaultService, CredentialService, SettingsService, $location, $routeParams, ShareService) { + .controller('ShareCtrl', ['$scope', 'VaultService', 'CredentialService', 'SettingsService', '$location', '$routeParams', 'ShareService', 'NotificationService', function ($scope, VaultService, CredentialService, SettingsService, $location, $routeParams, ShareService, NotificationService) { $scope.active_vault = VaultService.getActiveVault(); $scope.tabs = [{ @@ -60,7 +60,6 @@ angular.module('passmanApp') $location.path('/vault/' + $scope.storedCredential.vault_id); }; - console.log($location); $scope.share_link = $location.$$protocol + '://'+ $location.$$host + OC.generateUrl('apps/passman/share/public#') + $scope.storedCredential.guid; $scope.share_settings = { linkSharing:{ @@ -116,6 +115,16 @@ angular.module('passmanApp') } }; + $scope.unshareCredential = function(credential){ + ShareService.unshareCredential(credential).then(function(){ + var _credential = angular.copy(credential); + _credential.shared_key = null; + CredentialService.updateCredential(_credential).then(function () { + NotificationService.showNotification('Credential unshared', 4000) + }) + }) + } + $scope.applyShare = function(){ $scope.share_settings.cypher_progress.percent = 0; $scope.share_settings.cypher_progress.done = 0; diff --git a/js/templates.js b/js/templates.js index b7d797d9..61ed2d9a 100644 --- a/js/templates.js +++ b/js/templates.js @@ -107,7 +107,7 @@ angular.module('views/settings.html', []).run(['$templateCache', function($templ angular.module('views/share_credential.html', []).run(['$templateCache', function($templateCache) { 'use strict'; $templateCache.put('views/share_credential.html', - '
'); + '
'); }]); angular.module('views/show_vault.html', []).run(['$templateCache', function($templateCache) { diff --git a/templates/views/share_credential.html b/templates/views/share_credential.html index d8750aa1..31dc4d28 100644 --- a/templates/views/share_credential.html +++ b/templates/views/share_credential.html @@ -25,6 +25,7 @@ +