Skip to content

Commit

Permalink
fix(preferences(js)): set account id before importing certificate
Browse files Browse the repository at this point in the history
Fixes #5084
  • Loading branch information
cgx committed Jul 16, 2020
1 parent b78e66a commit 566fe55
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
16 changes: 14 additions & 2 deletions UI/MailerUI/UIxMailAccountActions.m
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -306,6 +306,7 @@ - (WOResponse *) importCertificateAction
if (password && pkcs12)
{
NSData *certificate;
NSDictionary *description;

certificate = [pkcs12 convertPKCS12ToPEMUsingPassword: password];

Expand All @@ -314,7 +315,18 @@ - (WOResponse *) importCertificateAction

[[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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
Expand Down
9 changes: 6 additions & 3 deletions UI/WebServerResources/js/Preferences/PreferencesController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -121,7 +123,6 @@
receiptAnyAction: "ignore"
}
});
index = this.preferences.defaults.AuxiliaryMailAccounts.length;

$mdDialog.show({
controller: 'AccountDialogController',
Expand All @@ -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',
Expand Down

0 comments on commit 566fe55

Please sign in to comment.