From aadf0ffa944ff1d14e703487d39450f051808554 Mon Sep 17 00:00:00 2001 From: manuroe Date: Tue, 6 Feb 2018 12:48:34 +0100 Subject: [PATCH 1/2] Spontaneous logout: Try to detect it in AuthenticationViewController and crash the app if it happens (#1643) --- .../AuthenticationViewController.m | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Riot/ViewController/AuthenticationViewController.m b/Riot/ViewController/AuthenticationViewController.m index ae0680906..f003d3ecf 100644 --- a/Riot/ViewController/AuthenticationViewController.m +++ b/Riot/ViewController/AuthenticationViewController.m @@ -196,6 +196,23 @@ [[AppDelegate theDelegate] trackScreen:@"Authentication"]; } +- (void)viewDidAppear:(BOOL)animated +{ + [super viewDidAppear:animated]; + + // Verify that the app does not show the authentification whereas the user + // has already logged in. + // This bug rarely happens (https://github.com/vector-im/riot-ios/issues/1643) + // but it invites the user to log in again. They will then lose all their e2e messages. + NSLog(@"[AuthenticationVC] viewDidAppear: Checking false logout"); + [[MXKAccountManager sharedManager] forceReloadAccounts]; + if ([MXKAccountManager sharedManager].activeAccounts) + { + // For now, we do not have better solution than forcing the user to restart the app + [NSException raise:@"False " format:@"AuthenticationViewController has been displayed whereas there is an existing account"]; + } +} + - (void)destroy { [super destroy]; From c04a5910d8f9f3aaf5b8629bea843585aaaeec07 Mon Sep 17 00:00:00 2001 From: manuroe Date: Tue, 6 Feb 2018 12:50:10 +0100 Subject: [PATCH 2/2] Spontaneous logout: Try to detect it in AuthenticationViewController and crash the app if it happens (#1643) --- Riot/ViewController/AuthenticationViewController.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Riot/ViewController/AuthenticationViewController.m b/Riot/ViewController/AuthenticationViewController.m index f003d3ecf..d1405a782 100644 --- a/Riot/ViewController/AuthenticationViewController.m +++ b/Riot/ViewController/AuthenticationViewController.m @@ -200,10 +200,11 @@ { [super viewDidAppear:animated]; - // Verify that the app does not show the authentification whereas the user - // has already logged in. + // Verify that the app does not show the authentification screean whereas + // the user has already logged in. // This bug rarely happens (https://github.com/vector-im/riot-ios/issues/1643) - // but it invites the user to log in again. They will then lose all their e2e messages. + // but it invites the user to log in again. They will then lose all their + // e2e messages. NSLog(@"[AuthenticationVC] viewDidAppear: Checking false logout"); [[MXKAccountManager sharedManager] forceReloadAccounts]; if ([MXKAccountManager sharedManager].activeAccounts)