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 /* 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 * 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 * it under the terms of the GNU General Public License as published by
@ -306,6 +306,7 @@
if (password && pkcs12) if (password && pkcs12)
{ {
NSData *certificate; NSData *certificate;
NSDictionary *description;
certificate = [pkcs12 convertPKCS12ToPEMUsingPassword: password]; certificate = [pkcs12 convertPKCS12ToPEMUsingPassword: password];
@ -314,7 +315,18 @@
[[self clientObject] setCertificate: certificate]; [[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; return response;

View File

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

View File

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