-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New: Option to change E2E key (#12169)
* Removed e2e password from alert message * Added strings to i18n * Adjusted i18n strings * Added a screen to allow users to change their encryption keys * Removed unused import * Declared global variables * Added e2e explanation on the password change screen * Hide Encryption area off the account page when encryption is disabled * Removed unused code
- Loading branch information
Showing
7 changed files
with
175 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<template name="accountEncryption"> | ||
<section class="preferences-page preferences-page--new"> | ||
{{#header sectionName="Encryption" buttons=true fullpage=true}} | ||
<div class="rc-header__section-button"> | ||
<button class="rc-button rc-button--primary" name="send" type="submit" data-button="create" form="encryption" {{canSave 'disabled'}}>{{_ "Save_changes"}}</button> | ||
</div> | ||
{{/header}} | ||
|
||
<div class="preferences-page__content"> | ||
<form id="encryption" autocomplete="off" class="container"> | ||
{{# if isEnabled}} | ||
<fieldset> | ||
<div class="section"> | ||
<div class="section-content border-component-color"> | ||
|
||
<div class="alert"> | ||
{{{_ "E2E_Encryption_Password_Explanation" }}} | ||
</div> | ||
|
||
<div class="rc-input{{#if confirmationKeyInvalid}} rc-input--error{{/if}} rc-w50 padded"> | ||
{{#with canChange=allowKeyChange}} | ||
<label class="rc-input__label"> | ||
<div class="rc-input__title">{{_ "New_encryption_key"}}</div> | ||
<div class="rc-input__wrapper"> | ||
<input name="encryptionKey" type="password" class="rc-input__element" placeholder="{{_ "New_Password_Placeholder"}}" autocomplete="new-password" {{ifThenElse canChange '' 'disabled'}}> | ||
</div> | ||
</label> | ||
{{#if canConfirmNewKey}} | ||
<label class="rc-input__label"> | ||
<div class="rc-input__title">{{_ "Confirm_new_encryption_key"}}</div> | ||
<div class="rc-input__wrapper"> | ||
<input name="confirmation-encryptionKey" type="password" class="rc-input__element" placeholder="{{_ "Confirm_New_Password_Placeholder"}}" autocomplete="confirm-new-password"> | ||
</div> | ||
</label> | ||
{{/if}} | ||
{{# unless canChange}} | ||
<div class="rc-input__description">{{_ 'EncryptionKey_Change_Disabled'}}</div> | ||
{{/unless}} | ||
{{/with}} | ||
</div> | ||
</div> | ||
</div> | ||
</fieldset> | ||
|
||
{{else}} | ||
{{_ "Admin_disabled_encryption"}} | ||
{{/if}} | ||
</form> | ||
</div> | ||
</section> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* globals Template, t, ReactiveVar */ | ||
import toastr from 'toastr'; | ||
import s from 'underscore.string'; | ||
import { RocketChat } from 'meteor/rocketchat:lib'; | ||
import { e2e } from 'meteor/rocketchat:e2e'; | ||
|
||
Template.accountEncryption.helpers({ | ||
isEnabled() { | ||
return RocketChat.settings.get('E2E_Enable'); | ||
}, | ||
allowKeyChange() { | ||
return localStorage.getItem('public_key') && localStorage.getItem('private_key'); | ||
}, | ||
canConfirmNewKey() { | ||
const encryptionKey = Template.instance().encryptionKey.get(); | ||
return encryptionKey && encryptionKey !== ''; | ||
}, | ||
ifThenElse(condition, val, not = '') { | ||
return condition ? val : not; | ||
}, | ||
canSave(ret) { | ||
const instance = Template.instance(); | ||
|
||
const encryptionKey = instance.encryptionKey.get(); | ||
const confirmationEncryptionKey = instance.confirmationEncryptionKey.get(); | ||
|
||
if ((!encryptionKey || encryptionKey !== confirmationEncryptionKey)) { | ||
return ret; | ||
} | ||
}, | ||
}); | ||
|
||
Template.accountEncryption.events({ | ||
'input [name=encryptionKey]'(e, instance) { | ||
instance.encryptionKey.set(e.target.value); | ||
|
||
if (e.target.value.length === 0) { | ||
instance.confirmationEncryptionKey.set(''); | ||
} | ||
}, | ||
'input [name=confirmation-encryptionKey]'(e, instance) { | ||
instance.confirmationEncryptionKey.set(e.target.value); | ||
}, | ||
'submit form'(e, instance) { | ||
e.preventDefault(); | ||
|
||
return instance.save(); | ||
}, | ||
}); | ||
|
||
Template.accountEncryption.onCreated(function() { | ||
const self = this; | ||
|
||
this.encryptionKey = new ReactiveVar; | ||
this.confirmationEncryptionKey = new ReactiveVar; | ||
|
||
this.save = function(cb) { | ||
const instance = this; | ||
const data = {}; | ||
|
||
if (s.trim(self.encryptionKey.get())) { | ||
data.newEncryptionKey = self.encryptionKey.get(); | ||
} | ||
|
||
if (Object.keys(data).length === 0) { | ||
return cb && cb(); | ||
} | ||
|
||
e2e.changePassword(data.newEncryptionKey); | ||
|
||
instance.clearForm(); | ||
toastr.remove(); | ||
this.encryptionKey.set(''); | ||
this.confirmationEncryptionKey.set(''); | ||
|
||
toastr.success(t('Encryption_key_saved_successfully')); | ||
}; | ||
|
||
this.clearForm = function() { | ||
this.find('[name=encryptionKey]').value = ''; | ||
this.find('[name=confirmation-encryptionKey]').value = ''; | ||
}; | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters