Multi session logut

This commit is contained in:
Aleksandrs Proskurins
2022-10-27 10:04:42 +03:00
parent 9282ff03aa
commit 14dd9f2414
6 changed files with 72 additions and 8 deletions
@@ -22,10 +22,11 @@ class AuthenticatedEndpointRequest: NSObject {
let path: String
let httpMethod: String
init(path: String, httpMethod: String) {
let params: [String: Any]
init(path: String, httpMethod: String, params: [String: Any]) {
self.path = path
self.httpMethod = httpMethod
self.params = params
super.init()
}
}
@@ -37,6 +38,15 @@ extension AuthenticatedEndpointRequest {
/// - Parameter deviceID: The device ID that is to be deleted.
static func deleteDevice(_ deviceID: String) -> AuthenticatedEndpointRequest {
let path = String(format: "%@/devices/%@", kMXAPIPrefixPathR0, MXTools.encodeURIComponent(deviceID))
return AuthenticatedEndpointRequest(path: path, httpMethod: "DELETE")
return AuthenticatedEndpointRequest(path: path, httpMethod: "DELETE", params: [:])
}
}
extension AuthenticatedEndpointRequest {
/// Create an authenticated request on `_matrix/client/r0/delete_devices`.
/// - Parameter deviceID: The device ID that is to be deleted.
static func deleteDevices(_ deviceIDs: [String]) -> AuthenticatedEndpointRequest {
let path = String(format: "%@/delete_devices", kMXAPIPrefixPathR0)
return AuthenticatedEndpointRequest(path: path, httpMethod: "POST", params: ["devices": deviceIDs])
}
}
@@ -131,7 +131,7 @@ final class UserInteractiveAuthenticationService: NSObject {
success: @escaping (MXAuthenticationSession?) -> Void,
failure: @escaping (Error) -> Void) -> MXHTTPOperation {
// Get the authentication flow required for this API
return self.session.matrixRestClient.authSessionForRequest(withMethod: request.httpMethod, path: request.path, parameters: [:], success: { [weak self] (authenticationSession) in
return self.session.matrixRestClient.authSessionForRequest(withMethod: request.httpMethod, path: request.path, parameters: request.params, success: { [weak self] (authenticationSession) in
guard let self = self else {
return
}