mirror of
https://github.com/nextcloud/passman.git
synced 2024-11-11 18:16:54 +08:00
34 lines
No EOL
1.4 KiB
JavaScript
34 lines
No EOL
1.4 KiB
JavaScript
/**
|
|
* Created by wolfi on 25/09/16.
|
|
*/
|
|
angular.module('passmanApp')
|
|
.controller('SharingSettingsCtrl', ['$scope', 'VaultService', 'CredentialService', 'SettingsService', '$location', '$routeParams', 'ShareService', 'EncryptService',
|
|
function ($scope, VaultService, CredentialService, SettingsService, $location, $routeParams, ShareService, EncryptService) {
|
|
$scope.active_vault = VaultService.getActiveVault();
|
|
$scope.sharing_keys = ShareService.getSharingKeys();
|
|
|
|
$scope.progress = 1;
|
|
$scope.generating = false;
|
|
|
|
$scope.generateKeys = function (length) {
|
|
$scope.progress = 1;
|
|
$scope.generating = true;
|
|
|
|
ShareService.generateRSAKeys(length).progress(function(progress){
|
|
$scope.progress = progress > 0 ? 2:1;
|
|
$scope.$digest();
|
|
}).then(function(kp){
|
|
console.log('stuff done');
|
|
$scope.generating = false;
|
|
|
|
var pem = ShareService.rsaKeyPairToPEM(kp)
|
|
|
|
$scope.active_vault.private_sharing_key = EncryptService.encryptString(pem.privateKey);
|
|
$scope.active_vault.public_sharing_key = pem.publicKey;
|
|
|
|
VaultService.updateSharingKeys($scope.active_vault).then(function (result) {
|
|
$scope.sharing_keys = ShareService.getSharingKeys();
|
|
})
|
|
});
|
|
}
|
|
}]); |