mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
Don't check scanned server against app config and use baseUrl from QR if available
This commit is contained in:
@@ -179,20 +179,18 @@ class AuthenticationService: AuthenticationServiceProtocol {
|
|||||||
return progressSubject.asCurrentValuePublisher()
|
return progressSubject.asCurrentValuePublisher()
|
||||||
}
|
}
|
||||||
|
|
||||||
// At some stage the SDK will have a `qrCodeData.intent` which we should check before continuing here.
|
// n.b. We rely on the SDK checking that the intent of the QR is suitable for us to login with.
|
||||||
// Note the equivalent check will also happen for linking a device by QR in the LinkNewDeviceService.
|
|
||||||
|
|
||||||
guard let scannedServerName = qrData.serverName() else {
|
// Future versions of the QR should always give us the baseUrl
|
||||||
|
guard let scannedServerNameOrBaseUrl = qrData.baseUrl() ?? qrData.serverName() else {
|
||||||
|
// With the older version of QR we treat the presence of serverName as meaning that the other device
|
||||||
|
// is not signed in.
|
||||||
MXLog.error("The QR code is from a device that is not yet signed in.")
|
MXLog.error("The QR code is from a device that is not yet signed in.")
|
||||||
progressSubject.send(completion: .failure(.qrCodeError(.deviceNotSignedIn)))
|
progressSubject.send(completion: .failure(.qrCodeError(.deviceNotSignedIn)))
|
||||||
return progressSubject.asCurrentValuePublisher()
|
return progressSubject.asCurrentValuePublisher()
|
||||||
}
|
}
|
||||||
|
|
||||||
if !appSettings.allowOtherAccountProviders, !appSettings.accountProviders.contains(scannedServerName) {
|
// n.b. We deliberatley don't check whether the received server is in our appSettings.accountProviders
|
||||||
MXLog.error("The scanned device's server is not allowed: \(scannedServerName)")
|
|
||||||
progressSubject.send(completion: .failure(.qrCodeError(.providerNotAllowed(scannedProvider: scannedServerName, allowedProviders: appSettings.accountProviders))))
|
|
||||||
return progressSubject.asCurrentValuePublisher()
|
|
||||||
}
|
|
||||||
|
|
||||||
let listener = SDKListener { progress in
|
let listener = SDKListener { progress in
|
||||||
guard let progress = QRLoginProgress(rustProgress: progress) else { return }
|
guard let progress = QRLoginProgress(rustProgress: progress) else { return }
|
||||||
@@ -201,7 +199,7 @@ class AuthenticationService: AuthenticationServiceProtocol {
|
|||||||
|
|
||||||
Task {
|
Task {
|
||||||
do {
|
do {
|
||||||
let client = try await makeClient(homeserverAddress: scannedServerName)
|
let client = try await makeClient(homeserverAddress: scannedServerNameOrBaseUrl)
|
||||||
let qrCodeHandler = client.newLoginWithQrCodeHandler(oidcConfiguration: appSettings.oidcConfiguration.rustValue)
|
let qrCodeHandler = client.newLoginWithQrCodeHandler(oidcConfiguration: appSettings.oidcConfiguration.rustValue)
|
||||||
try await qrCodeHandler.scan(qrCodeData: qrData, progressListener: listener)
|
try await qrCodeHandler.scan(qrCodeData: qrData, progressListener: listener)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user