From 5ba683d4b1e8fd97e0e895f7cae50f621a731221 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Fri, 12 Jan 2018 15:00:51 -0500 Subject: [PATCH] Web-based management of email certificate (cont'd) --- .../js/Mailer/Account.service.js | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/UI/WebServerResources/js/Mailer/Account.service.js b/UI/WebServerResources/js/Mailer/Account.service.js index 6ec15dda2..bf923caec 100644 --- a/UI/WebServerResources/js/Mailer/Account.service.js +++ b/UI/WebServerResources/js/Mailer/Account.service.js @@ -287,6 +287,30 @@ }); }; + /** + * @function $certificate + * @memberof Account.prototype + * @desc View the S/MIME certificate details associated to the account. + * @returns a promise of the HTTP operation + */ + Account.prototype.$certificate = function() { + var _this = this; + + if (this.security && this.security.hasCertificate) { + if (this.$$certificate) + return Account.$q.when(this.$$certificate); + else { + return Account.$$resource.fetch(this.id.toString(), 'certificate').then(function(data) { + _this.$$certificate = data; + return data; + }); + } + } + else { + return Account.$q.reject(); + } + }; + /** * @function $removeCertificate * @memberof Account.prototype @@ -296,7 +320,9 @@ Account.prototype.$removeCertificate = function() { var _this = this; - return Account.$$resource.fetch(this.id.toString(), 'removeCertificate'); + return Account.$$resource.fetch(this.id.toString(), 'removeCertificate').then(function() { + _this.security.hasCertificate = false; + }); }; /**