Merge pull request #5293 from vector-im/langleyd/5292_refresh_tokens

App: Refresh Tokens Implementation
This commit is contained in:
David Langley
2022-01-31 08:59:19 +00:00
committed by GitHub
23 changed files with 511 additions and 272 deletions

View File

@@ -81,8 +81,11 @@
NSMutableArray *cellData = [NSMutableArray array];
MXRestClient *mxRestClient = [[MXRestClient alloc] initWithCredentials:self.credentials andOnUnrecognizedCertificateBlock:nil andPersistentTokenDataHandler:^(void (^handler)(NSArray<MXCredentials *> *credentials, void (^completion)(BOOL didUpdateCredentials))) {
[[MXKAccountManager sharedManager] readAndWriteCredentials:handler];
} andUnauthenticatedHandler:nil];
// Add a fake matrix session to each room summary to provide it a REST client (used to handle correctly the room avatar).
MXSession *session = [[MXSession alloc] initWithMatrixRestClient:[[MXRestClient alloc] initWithCredentials:self.credentials andOnUnrecognizedCertificateBlock:nil]];
MXSession *session = [[MXSession alloc] initWithMatrixRestClient:mxRestClient];
for (id<MXRoomSummaryProtocol> summary in summaries)
{

View File

@@ -78,7 +78,14 @@
- (void)shareViewController:(ShareViewController *)shareViewController didRequestShareForRoomIdentifiers:(NSSet<NSString *> *)roomIdentifiers
{
MXSession *session = [[MXSession alloc] initWithMatrixRestClient:[[MXRestClient alloc] initWithCredentials:self.userAccount.mxCredentials andOnUnrecognizedCertificateBlock:nil]];
MXWeakify(self);
MXRestClient *restClient = [[MXRestClient alloc] initWithCredentials:self.userAccount.mxCredentials andOnUnrecognizedCertificateBlock:nil andPersistentTokenDataHandler:^(void (^handler)(NSArray<MXCredentials *> *credentials, void (^completion)(BOOL didUpdateCredentials))) {
[[MXKAccountManager sharedManager] readAndWriteCredentials:handler];
} andUnauthenticatedHandler:^(MXError *error, BOOL isSoftLogout, BOOL isRefreshTokenAuth, void (^completion)(void)) {
MXStrongifyAndReturnIfNil(self);
[self.userAccount handleUnauthenticatedWithError:error isSoftLogout:isSoftLogout isRefreshTokenAuth:isRefreshTokenAuth andCompletion:completion];
}];
MXSession *session = [[MXSession alloc] initWithMatrixRestClient:restClient];
[MXFileStore setPreloadOptions:0];
MXWeakify(session);
@@ -147,7 +154,7 @@
- (void)checkUserAccount
{
// Force account manager to reload account from the local storage.
[[MXKAccountManager sharedManager] forceReloadAccounts];
[MXKAccountManager sharedManagerWithReload:YES];
if (self.userAccount)
{