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; + }); }; /**