fix(preferences(js)): set account id before importing certificate

Fixes #5084
pull/285/head
Francis Lachapelle 2020-07-16 17:30:10 -04:00
parent b78e66a10b
commit 566fe55d71
3 changed files with 21 additions and 6 deletions

View File

@ -1,6 +1,6 @@
/* UIxMailAccountActions.m - this file is part of SOGo
*
* Copyright (C) 2007-2017 Inverse inc.
* Copyright (C) 2007-2020 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -306,6 +306,7 @@
if (password && pkcs12)
{
NSData *certificate;
NSDictionary *description;
certificate = [pkcs12 convertPKCS12ToPEMUsingPassword: password];
@ -314,7 +315,18 @@
[[self clientObject] setCertificate: certificate];
response = [self responseWith204];
description = [certificate certificateDescription];
if (description)
{
response = [self responseWithStatus: 200 andJSONRepresentation: description];
}
else
{
description = [NSDictionary
dictionaryWithObject: [self labelForKey: @"Error reading the certificate. Please install a new certificate."]
forKey: @"message"];
response = [self responseWithStatus: 500 andJSONRepresentation: description];
}
}
return response;

View File

@ -49,7 +49,7 @@
onSuccessItem: function(item, response, status, headers) {
this.clearQueue();
$timeout(function() {
_.assign(vm.account, {security: {hasCertificate: true}});
_.assign(vm.account, {security: {hasCertificate: true}, $$certificate: response});
});
_loadCertificate();
},

View File

@ -105,7 +105,9 @@
this.addMailAccount = function(ev, form) {
var account, index;
index = this.preferences.defaults.AuxiliaryMailAccounts.length;
account = new Account({
id: index,
isNew: true,
name: "",
identities: [
@ -121,7 +123,6 @@
receiptAnyAction: "ignore"
}
});
index = this.preferences.defaults.AuxiliaryMailAccounts.length;
$mdDialog.show({
controller: 'AccountDialogController',
@ -147,8 +148,10 @@
};
this.editMailAccount = function(event, index, form) {
var data = _.cloneDeep(this.preferences.defaults.AuxiliaryMailAccounts[index]);
var account = new Account(data);
var data, account;
data = _.assign({ id: index }, _.cloneDeep(this.preferences.defaults.AuxiliaryMailAccounts[index]));
account = new Account(data);
$mdDialog.show({
controller: 'AccountDialogController',
controllerAs: '$AccountDialogController',