From ece30590e2f9aa5703679b47cdd5f784a1ff64f1 Mon Sep 17 00:00:00 2001 From: Mauro Romito Date: Fri, 25 Aug 2023 17:09:52 +0200 Subject: [PATCH 1/3] helper function to generate the logout url --- .../AutoDiscovery/MXWellKnownAuthentication.h | 2 ++ .../AutoDiscovery/MXWellKnownAuthentication.m | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.h b/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.h index b224edf4e..23a7c2522 100644 --- a/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.h +++ b/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.h @@ -33,6 +33,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly) NSString *issuer; @property (nonatomic, readonly, nullable) NSString *account; +-(NSURL * _Nullable) getMasLogoutDeviceURLFromDeviceID: (NSString * ) deviceID; + @end NS_ASSUME_NONNULL_END diff --git a/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.m b/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.m index 2cce0def7..03dc13695 100644 --- a/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.m +++ b/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.m @@ -45,6 +45,23 @@ + (instancetype)modelFromJSON:(NSDictionary *)JSONDictionary return wellKnownAuthentication; } +-(NSURL * _Nullable) getMasLogoutDeviceURLFromDeviceID: (NSString * ) deviceID +{ + if (_account) + { + NSURLComponents *components = [NSURLComponents componentsWithString:_account]; + components.queryItems = @[ + [NSURLQueryItem queryItemWithName:@"device_id" value:deviceID], + [NSURLQueryItem queryItemWithName:@"action" value:@"session_end"] + ]; + return components.URL; + } + else + { + return nil; + } +} + #pragma mark - NSCoding From df726eede33b09479c9d3b4529efc745c02cf7f4 Mon Sep 17 00:00:00 2001 From: Mauro Romito Date: Fri, 25 Aug 2023 17:19:09 +0200 Subject: [PATCH 2/3] changelog --- changelog.d/pr-1813.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/pr-1813.feature diff --git a/changelog.d/pr-1813.feature b/changelog.d/pr-1813.feature new file mode 100644 index 000000000..b3859bb97 --- /dev/null +++ b/changelog.d/pr-1813.feature @@ -0,0 +1 @@ +Function that allows to generate from the well known authentication, a logout mas URL given the device ID. \ No newline at end of file From 6208987e7161850ff59e7ba8c61efe174a80e38d Mon Sep 17 00:00:00 2001 From: Mauro Romito Date: Fri, 25 Aug 2023 19:32:57 +0200 Subject: [PATCH 3/3] code improvement --- .../AutoDiscovery/MXWellKnownAuthentication.h | 2 +- .../AutoDiscovery/MXWellKnownAuthentication.m | 19 ++++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.h b/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.h index 23a7c2522..9c483c65e 100644 --- a/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.h +++ b/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.h @@ -33,7 +33,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly) NSString *issuer; @property (nonatomic, readonly, nullable) NSString *account; --(NSURL * _Nullable) getMasLogoutDeviceURLFromDeviceID: (NSString * ) deviceID; +-(NSURL * _Nullable) getLogoutDeviceURLFromID: (NSString * ) deviceID; @end diff --git a/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.m b/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.m index 03dc13695..fe2cdbdf6 100644 --- a/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.m +++ b/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.m @@ -45,21 +45,18 @@ + (instancetype)modelFromJSON:(NSDictionary *)JSONDictionary return wellKnownAuthentication; } --(NSURL * _Nullable) getMasLogoutDeviceURLFromDeviceID: (NSString * ) deviceID +-(NSURL * _Nullable) getLogoutDeviceURLFromID: (NSString * ) deviceID { - if (_account) - { - NSURLComponents *components = [NSURLComponents componentsWithString:_account]; - components.queryItems = @[ - [NSURLQueryItem queryItemWithName:@"device_id" value:deviceID], - [NSURLQueryItem queryItemWithName:@"action" value:@"session_end"] - ]; - return components.URL; - } - else + if (!_account) { return nil; } + NSURLComponents *components = [NSURLComponents componentsWithString:_account]; + components.queryItems = @[ + [NSURLQueryItem queryItemWithName:@"device_id" value:deviceID], + [NSURLQueryItem queryItemWithName:@"action" value:@"session_end"] + ]; + return components.URL; }