Merge remote-tracking branch 'origin/develop' into auth_forgot_password

This commit is contained in:
giomfo
2016-05-09 15:44:23 +02:00
15 changed files with 324 additions and 76 deletions
@@ -23,6 +23,17 @@
#import "VectorDesignValues.h"
@interface AuthenticationViewController ()
{
/**
Store the potential login error received by using the new default homeserver (vector.im)
while we retry a login process against the matrix.org HS.
*/
NSError *loginError;
}
@end
@implementation AuthenticationViewController
+ (UINib *)nib
@@ -232,6 +243,48 @@
}
}
- (void)onFailureDuringAuthRequest:(NSError *)error
{
// Homeserver migration: the default homeserver url has been updated with https://vector.im.
// The login process with an existing matrix.org accounts will then fail.
// Patch: Falling back to matrix.org HS so we don't break everyone's logins
if (self.authType == MXKAuthenticationTypeLogin)
{
if ([self.homeServerTextField.text isEqualToString:@"https://vector.im"])
{
MXError *mxError = [[MXError alloc] initWithNSError:error];
if (mxError && [mxError.errcode isEqualToString:kMXErrCodeStringForbidden])
{
// Retry against the matrix.org HS
NSLog(@"[MXKAuthenticationVC] Falling back to matrix.org HS");
loginError = error;
[self setHomeServerTextFieldText:@"https://matrix.org"];
[self onButtonPressed:self.submitButton];
return;
}
}
else if (loginError)
{
// This is not an existing matrix.org accounts
NSLog(@"[MXKAuthenticationVC] This is not an existing matrix.org accounts");
// Restore the default HS
[self setHomeServerTextFieldText: @"https://vector.im"];
// Consider the original login error
[super onFailureDuringAuthRequest:loginError];
loginError = nil;
return;
}
}
[super onFailureDuringAuthRequest:loginError];
}
#pragma mark -
- (void)hideServerOptionsContainer:(BOOL)hidden