Add resetOthers parameter to session creator method

This commit is contained in:
ismailgulek
2022-06-08 17:22:47 +03:00
parent 8df0cec21c
commit 4e696c36bc
6 changed files with 31 additions and 19 deletions
@@ -54,7 +54,7 @@ class LoginWizard {
/// - initialDeviceName: The initial device name.
/// - deviceID: The device ID, optional. If not provided or nil, the server will generate one.
/// - Returns: An `MXSession` if the login is successful.
func login(login: String, password: String, initialDeviceName: String, deviceID: String? = nil) async throws -> MXSession {
func login(login: String, password: String, initialDeviceName: String, deviceID: String? = nil, resetOthers: Bool = false) async throws -> MXSession {
let parameters: LoginPasswordParameters
if MXTools.isEmailAddress(login) {
@@ -70,16 +70,16 @@ class LoginWizard {
}
let credentials = try await client.login(parameters: parameters)
return sessionCreator.createSession(credentials: credentials, client: client)
return sessionCreator.createSession(credentials: credentials, client: client, resetOthers: resetOthers)
}
/// Exchange a login token to an access token.
/// - Parameter loginToken: A login token, obtained when login has happened in a WebView, using SSO.
/// - Returns: An `MXSession` if the login is successful.
func login(with token: String) async throws -> MXSession {
func login(with token: String, resetOthers: Bool = false) async throws -> MXSession {
let parameters = LoginTokenParameters(token: token)
let credentials = try await client.login(parameters: parameters)
return sessionCreator.createSession(credentials: credentials, client: client)
return sessionCreator.createSession(credentials: credentials, client: client, resetOthers: resetOthers)
}
// /// Login to the homeserver by sending a custom JsonDict.