Allow the app to be configured to bypass the server selection screen. (#4131)

* Make account provider configuration more flexible.

- Change defaultHomeserverAddress to an array of providers (needs UI).
- Add allowOtherAccountProviders to prevent the user from manually entering a provider.

* Refactor QR code scan failures into a common type.

* Validate scanned QR codes against the allowed account providers.

* Hide the login flow on the QR code screen when restricted.
This commit is contained in:
Doug
2025-05-20 11:09:50 +01:00
committed by GitHub
parent 10fb2b5dda
commit 390553f5fe
26 changed files with 326 additions and 111 deletions
+11 -5
View File
@@ -92,7 +92,8 @@ final class AppSettings {
// MARK: - Hooks
// swiftlint:disable:next function_parameter_count
func override(defaultHomeserverAddress: String,
func override(accountProviders: [String],
allowOtherAccountProviders: Bool,
pushGatewayBaseURL: URL,
oidcRedirectURL: URL,
websiteURL: URL,
@@ -109,7 +110,8 @@ final class AppSettings {
bugReportApplicationID: String,
analyticsTermsURL: URL?,
mapTilerConfiguration: MapTilerConfiguration) {
self.defaultHomeserverAddress = defaultHomeserverAddress
self.accountProviders = accountProviders
self.allowOtherAccountProviders = allowOtherAccountProviders
self.pushGatewayBaseURL = pushGatewayBaseURL
self.oidcRedirectURL = oidcRedirectURL
self.websiteURL = websiteURL
@@ -151,9 +153,13 @@ final class AppSettings {
@UserPreference(key: UserDefaultsKeys.seenInvites, defaultValue: [], storageType: .userDefaults(store))
var seenInvites: Set<String>
/// The default homeserver address used. This is intentionally a string without a scheme
/// so that it can be passed to Rust as a ServerName for well-known discovery.
private(set) var defaultHomeserverAddress = "matrix.org"
/// The initial set of account providers shown to the user in the authentication flow.
///
/// Account provider is the friendly term for the server name. It should not contain an `https` prefix and should
/// match the last part of the user ID. For example `example.com` and not `https://matrix.example.com`.
private(set) var accountProviders = ["matrix.org"]
/// Whether or not the user is allowed to manually enter their own account provider or must select from one of `defaultAccountProviders`.
private(set) var allowOtherAccountProviders = true
/// The task identifier used for background app refresh. Also used in main target's the Info.plist
let backgroundAppRefreshTaskIdentifier = "io.element.elementx.background.refresh"