Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,20 +179,18 @@
return progressSubject.asCurrentValuePublisher()
}

// At some stage the SDK will have a `qrCodeData.intent` which we should check before continuing here.
// Note the equivalent check will also happen for linking a device by QR in the LinkNewDeviceService.
// n.b. We rely on the SDK checking that the intent of the QR is suitable for us to login with.

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 {

Check failure on line 185 in ElementX/Sources/Services/Authentication/AuthenticationService.swift

View workflow job for this annotation

GitHub Actions / Tests

value of type 'QrCodeData' has no member 'baseUrl'

Check failure on line 185 in ElementX/Sources/Services/Authentication/AuthenticationService.swift

View workflow job for this annotation

GitHub Actions / Tests (Enterprise)

value of type 'QrCodeData' has no member 'baseUrl'
// 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.")
progressSubject.send(completion: .failure(.qrCodeError(.deviceNotSignedIn)))
return progressSubject.asCurrentValuePublisher()
}

if !appSettings.allowOtherAccountProviders, !appSettings.accountProviders.contains(scannedServerName) {
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()
}

// n.b. We deliberatley don't check whether the received server is in our appSettings.accountProviders

let listener = SDKListener { progress in
guard let progress = QRLoginProgress(rustProgress: progress) else { return }
Expand All @@ -201,7 +199,7 @@

Task {
do {
let client = try await makeClient(homeserverAddress: scannedServerName)
let client = try await makeClient(homeserverAddress: scannedServerNameOrBaseUrl)
let qrCodeHandler = client.newLoginWithQrCodeHandler(oidcConfiguration: appSettings.oidcConfiguration.rustValue)
try await qrCodeHandler.scan(qrCodeData: qrData, progressListener: listener)

Expand Down Expand Up @@ -281,6 +279,8 @@
.qrCodeError(.slidingSyncNotAvailable)
case .OtherDeviceNotSignedIn:
.qrCodeError(.deviceNotSignedIn)
case .UnsupportedQrCodeType:

Check failure on line 282 in ElementX/Sources/Services/Authentication/AuthenticationService.swift

View workflow job for this annotation

GitHub Actions / Tests

type 'HumanQrLoginError' has no member 'UnsupportedQrCodeType'

Check failure on line 282 in ElementX/Sources/Services/Authentication/AuthenticationService.swift

View workflow job for this annotation

GitHub Actions / Tests (Enterprise)

type 'HumanQrLoginError' has no member 'UnsupportedQrCodeType'
.qrCodeError(.invalidQRCode)
case .Unknown, .OidcMetadataInvalid, .CheckCodeAlreadySent, .CheckCodeCannotBeSent:
.qrCodeError(.unknown)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@
.cancelled
case .OtherDeviceAlreadySignedIn:
.deviceAlreadySignedIn
case .UnsupportedQrCodeType:

Check failure on line 204 in ElementX/Sources/Services/Authentication/LinkNewDeviceService.swift

View workflow job for this annotation

GitHub Actions / Tests

type 'HumanQrGrantLoginError' has no member 'UnsupportedQrCodeType'
.invalidQRCode
case .Unknown, .MissingSecretsBackup, .DeviceIdAlreadyInUse:
.unknown
}
Expand Down
Loading