mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-29 15:52:40 +00:00
Merge pull request #790 from vector-im/enabled_e2e_by_default
Crypto: Enable e2e by default
This commit is contained in:
commit
1a9c93bd74
2 changed files with 10 additions and 6 deletions
|
@ -1262,6 +1262,9 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN
|
|||
|
||||
- (void)initMatrixSessions
|
||||
{
|
||||
// Enable e2e encryption for newly created MXSession
|
||||
[MXSDKOptions sharedInstance].enableCryptoWhenStartingMXSession = YES;
|
||||
|
||||
// Disable identicon use
|
||||
[MXSDKOptions sharedInstance].disableIdenticonUseForUserAvatar = YES;
|
||||
|
||||
|
|
|
@ -1404,9 +1404,6 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
|
|||
UISwitch *switchButton = (UISwitch*)sender;
|
||||
MXKAccount* account = [MXKAccountManager sharedManager].activeAccounts.firstObject;
|
||||
|
||||
// Turn off by default the flag which is used to enable automatically the encryption on new sessions.
|
||||
[MXSDKOptions sharedInstance].enableCryptoWhenStartingMXSession = NO;
|
||||
|
||||
if (switchButton.isOn && !account.mxCredentials.deviceId.length)
|
||||
{
|
||||
// Prompt the user to log in again when no device id is available.
|
||||
|
@ -1438,9 +1435,6 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
|
|||
__strong __typeof(weakSelf)strongSelf = weakSelf;
|
||||
strongSelf->currentAlert = nil;
|
||||
|
||||
// Turn on encryption on new sessions after signing off
|
||||
[MXSDKOptions sharedInstance].enableCryptoWhenStartingMXSession = YES;
|
||||
|
||||
switchButton.enabled = NO;
|
||||
[strongSelf startActivityIndicator];
|
||||
|
||||
|
@ -1463,6 +1457,13 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
|
|||
MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0];
|
||||
[session enableCrypto:switchButton.isOn success:^{
|
||||
|
||||
// When disabling crypto, reset the current device id as it cannot be reused.
|
||||
// This means that the user will need to log in again if he wants to re-enable e2e.
|
||||
if (!switchButton.isOn)
|
||||
{
|
||||
[account resetDeviceId];
|
||||
}
|
||||
|
||||
// Reload all data source of encrypted rooms
|
||||
MXKRoomDataSourceManager *roomDataSourceManager = [MXKRoomDataSourceManager sharedManagerForMatrixSession:session];
|
||||
|
||||
|
|
Loading…
Reference in a new issue