Disable E2EE if master password is invalid
This commit is contained in:
parent
8b180ea423
commit
34e2833555
|
@ -37,17 +37,10 @@ export default new class E2EE extends BuiltinModule {
|
||||||
this.handlePublicKey = this.handlePublicKey.bind(this);
|
this.handlePublicKey = this.handlePublicKey.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Handle bad master key
|
|
||||||
async enabled(e) {
|
async enabled(e) {
|
||||||
Events.on('discord:MESSAGE_CREATE', this.handlePublicKey);
|
|
||||||
seed = Security.randomBytes();
|
|
||||||
let newMaster = '';
|
|
||||||
try {
|
try {
|
||||||
newMaster = await Modals.input('E2EE', 'Master Key:', true).promise;
|
const newMaster = await Modals.input('Open Database', 'Master Password', true).promise;
|
||||||
} catch (err) {
|
this.setMaster(newMaster);
|
||||||
Toasts.error('Failed to set master key!');
|
|
||||||
}
|
|
||||||
this.master = Security.encrypt(seed, newMaster);
|
|
||||||
this.patchDispatcher();
|
this.patchDispatcher();
|
||||||
this.patchMessageContent();
|
this.patchMessageContent();
|
||||||
const selector = '.' + WebpackModules.getClassName('channelTextArea', 'emojiButton');
|
const selector = '.' + WebpackModules.getClassName('channelTextArea', 'emojiButton');
|
||||||
|
@ -55,6 +48,10 @@ export default new class E2EE extends BuiltinModule {
|
||||||
this.patchChannelTextArea(cta);
|
this.patchChannelTextArea(cta);
|
||||||
this.patchChannelTextAreaSubmit(cta);
|
this.patchChannelTextAreaSubmit(cta);
|
||||||
cta.forceUpdateAll();
|
cta.forceUpdateAll();
|
||||||
|
} catch (err) {
|
||||||
|
Settings.getSetting(...this.settingPath).value = false;
|
||||||
|
Toasts.error('Invalid master password! E2EE Disabled');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async disabled(e) {
|
async disabled(e) {
|
||||||
|
|
Loading…
Reference in New Issue