fix(mail(js)): hide sign and encrypt options if not usable

When composing a message, don't offer to sign nor encrypt the message
if user has not uploaded a certificate or if S/MIME is disabled.
pull/301/head
Francis Lachapelle 2021-08-12 13:40:35 -04:00
parent 3388c18466
commit eb46415711
4 changed files with 19 additions and 9 deletions

View File

@ -945,7 +945,7 @@
[mailAccount setObject: delegates forKey: @"delegates"];
// 9. Security
if ([[_defaults mailCertificate] length])
if ([[self domainDefaults] mailCertificateEnabled] && [[_defaults mailCertificate] length])
{
security = [NSMutableDictionary new];

View File

@ -410,7 +410,7 @@ static SoProduct *preferencesProduct = nil;
{
auxAccount = [accounts objectAtIndex: i];
security = [auxAccount objectForKey: @"security"];
if (security)
if (security && [domainDefaults mailCertificateEnabled])
{
limitedSecurity = [NSMutableDictionary dictionaryWithDictionary: security];
if ([limitedSecurity objectForKey: @"certificate"])

View File

@ -231,15 +231,15 @@
<var:string label:value="Return Receipt"/>
</sg-checkmark>
</md-menu-item>
<md-menu-item>
<md-menu-item ng-show="editor.account.$hasCertificate()">
<md-button class="md-primary" ng-disabled="true" ng-bind="::'Security' | loc"><!-- Security --></md-button>
</md-menu-item>
<md-menu-item>
<md-menu-item ng-show="::editor.account.$hasCertificate()">
<sg-checkmark ng-model="editor.message.editable.sign">
<var:string label:value="Sign"/>
</sg-checkmark>
</md-menu-item>
<md-menu-item>
<md-menu-item ng-show="::editor.account.$hasCertificate()">
<sg-checkmark ng-model="editor.message.editable.encrypt">
<var:string label:value="Encrypt"/>
</sg-checkmark>
@ -248,7 +248,7 @@
<md-button class="md-primary" ng-disabled="true"><var:string label:value="Priority"/></md-button>
</md-menu-item>
<md-menu-item>
<md-button ng-click="editor.message.editable.priority = 1">
<md-button ng-click="::editor.message.editable.priority = 1">
<md-icon>{{ editor.message.editable.priority == 1 ? 'check' : null }}</md-icon>
<var:string label:value="highest"/>
</md-button>
@ -286,7 +286,7 @@
<!-- MESSAGE CONTENT -->
<md-input-container class="md-block sg-mail-editor-content">
<textarea name="content" class="plain-text"
ng-if="editor.composeType == 'text'"
ng-if="::(editor.composeType == 'text')"
rows="9"
ng-model="editor.message.editable.text"
ng-focus="editor.onTextFocus($event)"
@ -296,7 +296,7 @@
sg-autogrow="true"
md-detect-hidden="md-detect-hidden"><!-- plain text editor --></textarea>
<sg-ckeditor id="message-content"
ng-if="editor.composeType == 'html'"
ng-if="::(editor.composeType == 'html')"
config="editor.ckConfig"
on-instance-ready="editor.onHTMLReady($editor)"
on-focus="editor.onHTMLFocus($editor)"

View File

@ -392,6 +392,16 @@
return identity.textSignature;
};
/**
* @function $hasCertificate
* @memberof Account.prototype
* @desc Return true if the user has a S/MIME certificate for this account
* @returns a boolean value
*/
Account.prototype.$hasCertificate = function() {
return this.security && this.security.hasCertificate;
};
/**
* @function $certificate
* @memberof Account.prototype
@ -401,7 +411,7 @@
Account.prototype.$certificate = function() {
var _this = this;
if (this.security && this.security.hasCertificate) {
if (this.$hasCertificate()) {
if (this.$$certificate)
return Account.$q.when(this.$$certificate);
else {