Merge branch 'develop' into ismail/5096_thread_notifications

This commit is contained in:
ismailgulek
2022-02-01 01:23:00 +03:00
88 changed files with 7572 additions and 559 deletions
@@ -193,8 +193,11 @@
/**
Handle supported flows and associated information returned by the homeserver.
@param authSession The session to be handled.
@param fallbackSSOFlow A fallback SSO flow to be shown when the session has none
e.g. A login SSO flow that can be shown for a registration session.
*/
- (void)handleAuthenticationSession:(MXAuthenticationSession *)authSession;
- (void)handleAuthenticationSession:(MXAuthenticationSession *)authSession withFallbackSSOFlow:(MXLoginSSOFlow *)fallbackSSOFlow;
/**
Customize the MXHTTPClientOnUnrecognizedCertificate block that will be used to handle unrecognized certificate observed during authentication challenge from a server.
@@ -219,6 +222,11 @@
*/
- (void)testUserRegistration:(void (^)(MXError *mxError))callback;
/**
Searches an array of `MXLoginFlow` returning the first valid `MXLoginSSOFlow` found.
*/
- (MXLoginSSOFlow*)loginSSOFlowWithProvidersFromFlows:(NSArray<MXLoginFlow*>*)loginFlows;
/**
Action registered on the following events:
- 'UIControlEventTouchUpInside' for each UIButton instance.
@@ -621,41 +621,51 @@
// Reset potential authentication fallback url
authenticationFallback = nil;
if (mxRestClient)
if (mxRestClient && (self.authType == MXKAuthenticationTypeLogin || self.authType == MXKAuthenticationTypeRegister))
{
if (_authType == MXKAuthenticationTypeLogin)
{
mxCurrentOperation = [mxRestClient getLoginSession:^(MXAuthenticationSession* authSession) {
[self handleAuthenticationSession:authSession];
} failure:^(NSError *error) {
[self onFailureDuringMXOperation:error];
}];
}
else if (_authType == MXKAuthenticationTypeRegister)
{
mxCurrentOperation = [mxRestClient getRegisterSession:^(MXAuthenticationSession* authSession){
[self handleAuthenticationSession:authSession];
} failure:^(NSError *error){
[self onFailureDuringMXOperation:error];
}];
}
else
{
// Not supported for other types
MXLogDebug(@"[MXKAuthenticationVC] refreshAuthenticationSession is ignored");
}
MXWeakify(self);
// Get the login session to determine available SSO flows.
mxCurrentOperation = [mxRestClient getLoginSession:^(MXAuthenticationSession* loginAuthSession) {
MXStrongifyAndReturnIfNil(self);
if (self.authType == MXKAuthenticationTypeRegister)
{
MXWeakify(self);
self->mxCurrentOperation = [self->mxRestClient getRegisterSession:^(MXAuthenticationSession* registerAuthSession) {
MXStrongifyAndReturnIfNil(self);
// Handle the register session along with any SSO flows from the login session
MXLoginSSOFlow *loginSSOFlow = [self loginSSOFlowWithProvidersFromFlows:loginAuthSession.flows];
[self handleAuthenticationSession:registerAuthSession withFallbackSSOFlow:loginSSOFlow];
} failure:^(NSError *error) {
[self onFailureDuringMXOperation:error];
}];
}
else
{
// Handle the login session by itself
[self handleAuthenticationSession:loginAuthSession withFallbackSSOFlow:nil];
}
} failure:^(NSError *error) {
MXStrongifyAndReturnIfNil(self);
[self onFailureDuringMXOperation:error];
}];
}
else
{
// Not supported for other types
MXLogDebug(@"[MXKAuthenticationVC] refreshAuthenticationSession is ignored");
}
}
- (void)handleAuthenticationSession:(MXAuthenticationSession *)authSession
- (void)handleAuthenticationSession:(MXAuthenticationSession *)authSession withFallbackSSOFlow:(MXLoginSSOFlow *)fallbackSSOFlow
{
mxCurrentOperation = nil;
@@ -901,6 +911,27 @@
mxCurrentOperation = [mxRestClient testUserRegistration:self.authInputsView.userId callback:callback];
}
- (MXLoginSSOFlow*)loginSSOFlowWithProvidersFromFlows:(NSArray<MXLoginFlow*>*)loginFlows
{
MXLoginSSOFlow *ssoFlowWithProviders;
for (MXLoginFlow *loginFlow in loginFlows)
{
if ([loginFlow isKindOfClass:MXLoginSSOFlow.class])
{
MXLoginSSOFlow *ssoFlow = (MXLoginSSOFlow *)loginFlow;
if (ssoFlow.identityProviders.count)
{
ssoFlowWithProviders = ssoFlow;
break;
}
}
}
return ssoFlowWithProviders;
}
- (IBAction)onButtonPressed:(id)sender
{
[self dismissKeyboard];
@@ -1451,7 +1482,9 @@
MXRestClient *mxRestClient = [[MXRestClient alloc] initWithCredentials:credentials andOnUnrecognizedCertificateBlock:^BOOL(NSData *certificate) {
return NO;
}];
} andPersistentTokenDataHandler:^(void (^handler)(NSArray<MXCredentials *> *credentials, void (^completion)(BOOL didUpdateCredentials))) {
[[MXKAccountManager sharedManager] readAndWriteCredentials:handler];
} andUnauthenticatedHandler: nil];
MXWeakify(self);
[[MXKAccountManager sharedManager].dehydrationService rehydrateDeviceWithMatrixRestClient:mxRestClient dehydrationKey:keyData success:^(NSString * deviceId) {