mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-17 15:09:31 +02:00
Feat: add a flag in the build settings to force the user to define a homeserver.
This commit is contained in:
@@ -98,10 +98,15 @@ final class BuildSettings: NSObject {
|
||||
|
||||
// MARK: - Server configuration
|
||||
|
||||
// Default servers proposed on the authentication screen
|
||||
// Force the user to set a homeserver instead of using the default one
|
||||
static let forceHomeserverSelection = false
|
||||
|
||||
// Default server proposed on the authentication screen
|
||||
static let serverConfigDefaultHomeserverUrlString = "https://matrix.org"
|
||||
static let serverConfigDefaultIdentityServerUrlString = "https://vector.im"
|
||||
|
||||
// Default identity server
|
||||
static let serverConfigDefaultIdentityServerUrlString = "https://vector.im"
|
||||
|
||||
static let serverConfigSygnalAPIUrlString = "https://matrix.org/_matrix/push/v1/notify"
|
||||
|
||||
|
||||
|
||||
@@ -130,9 +130,19 @@ final class AuthenticationCoordinator: NSObject, AuthenticationCoordinatorProtoc
|
||||
}
|
||||
|
||||
let flow: AuthenticationFlow = initialScreen == .login ? .login : .register
|
||||
|
||||
// Use the homeserver defined by a provisioningLink or by the user (if none is set, the default one will be used)
|
||||
let homeserverAddress = authenticationService.provisioningLink?.homeserverUrl ?? authenticationService.state.homeserver.addressFromUser
|
||||
|
||||
// Check if the user must select a server
|
||||
if BuildSettings.forceHomeserverSelection, homeserverAddress == nil {
|
||||
showServerSelectionScreen(for: flow)
|
||||
return
|
||||
}
|
||||
|
||||
do {
|
||||
// Start the flow using the default server (or a provisioning link if set).
|
||||
try await authenticationService.startFlow(flow)
|
||||
// Start the flow (if homeserverAddress is nil, the default server will be used).
|
||||
try await authenticationService.startFlow(flow, for: homeserverAddress)
|
||||
} catch {
|
||||
MXLog.error("[AuthenticationCoordinator] start: Failed to start, showing server selection.")
|
||||
showServerSelectionScreen(for: flow)
|
||||
|
||||
@@ -132,7 +132,14 @@ static const CGFloat kAuthInputContainerViewMinHeightConstraintConstant = 150.0;
|
||||
target:self
|
||||
action:@selector(onButtonPressed:)];
|
||||
|
||||
self.defaultHomeServerUrl = RiotSettings.shared.homeserverUrlString;
|
||||
if (BuildSettings.forceHomeserverSelection)
|
||||
{
|
||||
self.defaultHomeServerUrl = nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
self.defaultHomeServerUrl = RiotSettings.shared.homeserverUrlString;
|
||||
}
|
||||
|
||||
self.defaultIdentityServerUrl = RiotSettings.shared.identityServerUrlString;
|
||||
|
||||
@@ -1207,7 +1214,14 @@ static const CGFloat kAuthInputContainerViewMinHeightConstraintConstant = 150.0;
|
||||
[self saveCustomServerInputs];
|
||||
|
||||
// Restore default configuration
|
||||
[self setHomeServerTextFieldText:self.defaultHomeServerUrl];
|
||||
if (BuildSettings.forceHomeserverSelection)
|
||||
{
|
||||
[self setHomeServerTextFieldText:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self setHomeServerTextFieldText:self.defaultHomeServerUrl];
|
||||
}
|
||||
[self setIdentityServerTextFieldText:self.defaultIdentityServerUrl];
|
||||
|
||||
[self.customServersTickButton setImage:AssetImages.selectionUntick.image forState:UIControlStateNormal];
|
||||
|
||||
@@ -86,6 +86,10 @@ class HomeserverAddress: NSObject {
|
||||
/// - Ensure the address contains a scheme, otherwise make it `https`.
|
||||
/// - Remove any trailing slashes.
|
||||
static func sanitized(_ address: String) -> String {
|
||||
guard !address.isEmpty else {
|
||||
// prevent prefixing an empty string with "https:"
|
||||
return address
|
||||
}
|
||||
var address = address.trimmingCharacters(in: .whitespacesAndNewlines).lowercased()
|
||||
|
||||
if !address.contains("://") {
|
||||
|
||||
@@ -57,7 +57,13 @@ final class AuthenticationServerSelectionCoordinator: Coordinator, Presentable {
|
||||
self.parameters = parameters
|
||||
|
||||
let homeserver = parameters.authenticationService.state.homeserver
|
||||
let viewModel = AuthenticationServerSelectionViewModel(homeserverAddress: homeserver.displayableAddress,
|
||||
let homeserverAddress: String
|
||||
if BuildSettings.forceHomeserverSelection, homeserver.addressFromUser == nil {
|
||||
homeserverAddress = ""
|
||||
} else {
|
||||
homeserverAddress = homeserver.displayableAddress
|
||||
}
|
||||
let viewModel = AuthenticationServerSelectionViewModel(homeserverAddress: homeserverAddress,
|
||||
flow: parameters.authenticationService.state.flow,
|
||||
hasModalPresentation: parameters.hasModalPresentation)
|
||||
let view = AuthenticationServerSelectionScreen(viewModel: viewModel.context)
|
||||
|
||||
1
changelog.d/pr-7541.change
Normal file
1
changelog.d/pr-7541.change
Normal file
@@ -0,0 +1 @@
|
||||
Add a flag in the build settings to force the user to define a homeserver instead of using the default one.
|
||||
Reference in New Issue
Block a user