Desktop: Fix handling of disabled master keys when enabling E2EE

pull/5448/head
Laurent Cozic 2021-09-09 18:46:58 +01:00
parent 267c32143b
commit d33b99cffb
3 changed files with 7 additions and 13 deletions

View File

@ -270,11 +270,7 @@ class EncryptionConfigScreenComponent extends React.Component<Props> {
const onToggleButtonClick = async () => {
const isEnabled = getEncryptionEnabled();
let masterKey = getDefaultMasterKey();
// If the user has explicitly disabled the master key, we generate a
// new one. Needed for one the password has been forgotten.
if (masterKey && !masterKey.enabled) masterKey = null;
const masterKey = getDefaultMasterKey();
let answer = null;
if (isEnabled) {

View File

@ -145,11 +145,7 @@ class EncryptionConfigScreenComponent extends BaseScreenComponent<Props> {
passwordPromptComponent() {
const theme = themeStyle(this.props.themeId);
let masterKey = getDefaultMasterKey();
// If the user has explicitly disabled the master key, we generate a
// new one. Needed for one the password has been forgotten.
if (!masterKey.enabled) masterKey = null;
const masterKey = getDefaultMasterKey();
const onEnableClick = async () => {
try {

View File

@ -161,7 +161,9 @@ export function showMissingMasterKeyMessage(syncInfo: SyncInfo, notLoadedMasterK
}
export function getDefaultMasterKey(): MasterKeyEntity {
const mk = getActiveMasterKey();
if (mk) return mk;
return MasterKey.latest();
let mk = getActiveMasterKey();
if (!mk || !mk.enabled) {
mk = MasterKey.latest();
}
return mk && mk.enabled ? mk : null;
}