mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-06-11 05:19:43 +00:00
Initial Web-based management of email certificate
This commit is contained in:
@@ -20,7 +20,8 @@
|
||||
var alert = this.$modal.alert()
|
||||
.title(title)
|
||||
.htmlContent(content)
|
||||
.ok(l('OK'));
|
||||
.ok(l('OK'))
|
||||
.multiple(true);
|
||||
this.$modal.show(alert);
|
||||
};
|
||||
|
||||
|
||||
@@ -287,6 +287,18 @@
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @function $removeCertificate
|
||||
* @memberof Account.prototype
|
||||
* @desc Remove any S/MIME certificate associated with the account.
|
||||
* @returns a promise of the HTTP operation
|
||||
*/
|
||||
Account.prototype.$removeCertificate = function() {
|
||||
var _this = this;
|
||||
|
||||
return Account.$$resource.fetch(this.id.toString(), 'removeCertificate');
|
||||
};
|
||||
|
||||
/**
|
||||
* @function updateQuota
|
||||
* @memberof Account.prototype
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
AccountDialogController.$inject = ['$mdDialog', 'defaults', 'account', 'accountId', 'mailCustomFromEnabled'];
|
||||
function AccountDialogController($mdDialog, defaults, account, accountId, mailCustomFromEnabled) {
|
||||
AccountDialogController.$inject = ['$mdDialog', '$mdToast', 'FileUploader', 'Dialog', 'sgSettings', 'Account', 'defaults', 'account', 'accountId', 'mailCustomFromEnabled'];
|
||||
function AccountDialogController($mdDialog, $mdToast, FileUploader, Dialog, Settings, Account, defaults, account, accountId, mailCustomFromEnabled) {
|
||||
var vm = this;
|
||||
|
||||
vm.defaultPort = 143;
|
||||
@@ -16,6 +16,10 @@
|
||||
vm.account = account;
|
||||
vm.accountId = accountId;
|
||||
vm.customFromIsReadonly = customFromIsReadonly;
|
||||
vm.onBeforeUploadCertificate = onBeforeUploadCertificate;
|
||||
vm.certificateIsInstalled = certificateIsInstalled;
|
||||
vm.removeCertificate = removeCertificate;
|
||||
vm.importCertificate = importCertificate;
|
||||
vm.cancel = cancel;
|
||||
vm.save = save;
|
||||
vm.hostnameRE = accountId > 0 ? /^(?!(127\.0\.0\.1|localhost(?:\.localdomain)?)$)/ : /./;
|
||||
@@ -25,13 +29,65 @@
|
||||
else if (vm.account.encryption == "ssl")
|
||||
vm.defaultPort = 993;
|
||||
|
||||
if (vm.account.certificateFilename)
|
||||
vm.certificateFilename = vm.account.certificateFilename;
|
||||
|
||||
vm.uploader = new FileUploader({
|
||||
url: [Settings.activeUser('folderURL') + 'Mail', accountId, 'importCertificate'].join('/'),
|
||||
autoUpload: false,
|
||||
queueLimit: 1,
|
||||
filters: [{ name: filterByExtension, fn: filterByExtension }],
|
||||
onAfterAddingFile: function(item) {
|
||||
vm.certificateFilename = item.file.name;
|
||||
},
|
||||
onSuccessItem: function(item, response, status, headers) {
|
||||
var el = angular.element(document.getElementById('accountSecurityContent'));
|
||||
$mdToast.show(
|
||||
$mdToast.simple()
|
||||
.content(l('Success'))
|
||||
.parent(el)
|
||||
.position('top right')
|
||||
.hideDelay(3000));
|
||||
this.clearQueue();
|
||||
},
|
||||
onErrorItem: function(item, response, status, headers) {
|
||||
Dialog.alert(l('Error'), l('An error occurred while importing the certificate. Verify your password.'));
|
||||
}
|
||||
});
|
||||
|
||||
function filterByExtension(item) {
|
||||
var isP12File = item.type.indexOf('pkcs12') > 0 || /\.(p12|pfx)$/.test(item.name);
|
||||
vm.form.certificateFilename.$setValidity('fileformat', isP12File);
|
||||
return isP12File;
|
||||
}
|
||||
|
||||
function customFromIsReadonly() {
|
||||
if (accountId > 0)
|
||||
return false;
|
||||
|
||||
return !mailCustomFromEnabled;
|
||||
}
|
||||
|
||||
function importCertificate() {
|
||||
vm.uploader.queue[0].formData = [{ password: vm.certificatePassword }];
|
||||
vm.uploader.uploadAll();
|
||||
}
|
||||
|
||||
function onBeforeUploadCertificate(form) {
|
||||
vm.form = form;
|
||||
vm.uploader.clearQueue();
|
||||
}
|
||||
|
||||
function certificateIsInstalled() {
|
||||
return vm.certificateFilename && vm.uploader.queue.length === 0;
|
||||
}
|
||||
|
||||
function removeCertificate() {
|
||||
var accountObject = new Account({ id: accountId });
|
||||
accountObject.$removeCertificate().then(function() {
|
||||
delete vm.certificateFilename;
|
||||
});
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
$mdDialog.cancel();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
angular.module('SOGo.PreferencesUI', ['ui.router', 'ck', 'SOGo.Common', 'SOGo.MailerUI', 'SOGo.ContactsUI', 'SOGo.Authentication', 'as.sortable'])
|
||||
angular.module('SOGo.PreferencesUI', ['ui.router', 'ck', 'angularFileUpload', 'SOGo.Common', 'SOGo.MailerUI', 'SOGo.ContactsUI', 'SOGo.Authentication', 'as.sortable'])
|
||||
.config(configure)
|
||||
.run(runBlock);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user