diff --git a/DesignKit/Source/ColorValues.swift b/DesignKit/Source/ColorValues.swift index 4e693a24e..338d1cfe8 100644 --- a/DesignKit/Source/ColorValues.swift +++ b/DesignKit/Source/ColorValues.swift @@ -46,8 +46,6 @@ public struct ColorValues: Colors { public let background: UIColor - public let white: UIColor - public let ems: UIColor public let namesAndAvatars: [UIColor] diff --git a/DesignKit/Source/Colors.swift b/DesignKit/Source/Colors.swift index dd19287cc..bf3e9abd3 100644 --- a/DesignKit/Source/Colors.swift +++ b/DesignKit/Source/Colors.swift @@ -64,9 +64,6 @@ public protocol Colors { /// Background UI color var background: ColorType { get } - /// Global color: The color white. - var white: ColorType { get } - /// Global color: The EMS brand's purple colour. var ems: ColorType { get } diff --git a/DesignKit/Source/ColorsSwiftUI.swift b/DesignKit/Source/ColorsSwiftUI.swift index 0dade5618..b685ac0d7 100644 --- a/DesignKit/Source/ColorsSwiftUI.swift +++ b/DesignKit/Source/ColorsSwiftUI.swift @@ -47,8 +47,6 @@ public struct ColorSwiftUI: Colors { public let background: Color - public var white: Color - public var ems: Color public let namesAndAvatars: [Color] @@ -66,7 +64,6 @@ public struct ColorSwiftUI: Colors { tile = Color(values.tile) navigation = Color(values.navigation) background = Color(values.background) - white = Color(values.white) ems = Color(values.ems) namesAndAvatars = values.namesAndAvatars.map({ Color($0) }) } diff --git a/DesignKit/Variants/Colors/Dark/DarkColors.swift b/DesignKit/Variants/Colors/Dark/DarkColors.swift index 30d4d111a..24678fcd0 100644 --- a/DesignKit/Variants/Colors/Dark/DarkColors.swift +++ b/DesignKit/Variants/Colors/Dark/DarkColors.swift @@ -33,7 +33,6 @@ public class DarkColors { tile: UIColor(rgb:0x394049), navigation: UIColor(rgb:0x21262C), background: UIColor(rgb:0x15191E), - white: UIColor(rgb: 0xFFFFFF), ems: UIColor(rgb: 0x7E69FF), namesAndAvatars: [ UIColor(rgb:0x368BD6), diff --git a/DesignKit/Variants/Colors/Light/LightColors.swift b/DesignKit/Variants/Colors/Light/LightColors.swift index 972c75ff6..332a24162 100644 --- a/DesignKit/Variants/Colors/Light/LightColors.swift +++ b/DesignKit/Variants/Colors/Light/LightColors.swift @@ -34,7 +34,6 @@ public class LightColors { tile: UIColor(rgb:0xF3F8FD), navigation: UIColor(rgb:0xF4F6FA), background: UIColor(rgb:0xFFFFFF), - white: UIColor(rgb: 0xFFFFFF), ems: UIColor(rgb: 0x7E69FF), namesAndAvatars: [ UIColor(rgb:0x368BD6), diff --git a/Riot/Modules/Onboarding/AuthenticationCoordinator.swift b/Riot/Modules/Onboarding/AuthenticationCoordinator.swift index 8609535aa..bd2409670 100644 --- a/Riot/Modules/Onboarding/AuthenticationCoordinator.swift +++ b/Riot/Modules/Onboarding/AuthenticationCoordinator.swift @@ -114,6 +114,7 @@ final class AuthenticationCoordinator: NSObject, AuthenticationCoordinatorProtoc // MARK: - Private + /// Presents an alert on top of the navigation router, using the supplied error's `localizedDescription`. @MainActor func displayError(_ error: Error) { let alert = UIAlertController(title: VectorL10n.error, message: error.localizedDescription, diff --git a/Riot/Modules/Onboarding/AuthenticationCoordinatorState.swift b/Riot/Modules/Onboarding/AuthenticationCoordinatorState.swift deleted file mode 100644 index 9eebfda03..000000000 --- a/Riot/Modules/Onboarding/AuthenticationCoordinatorState.swift +++ /dev/null @@ -1,41 +0,0 @@ -// -// Copyright 2022 New Vector Ltd -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -import Foundation -import MatrixSDK - -@available(iOS 14.0, *) -struct AuthenticationCoordinatorState { - // MARK: User choices - // var serverType: ServerType = .unknown - // var signMode: SignMode = .unknown - var resetPasswordEmail: String? - - /// The homeserver address as returned by the server. - var homeserverAddress: String? - /// The homeserver address as input by the user (it can differ to the well-known request). - var homeserverAddressFromUser: String? - - /// For SSO session recovery - var deviceId: String? - - // MARK: Network result - var loginMode: LoginMode = .unknown - /// Supported types for the login. - var loginModeSupportedTypes = [MXLoginFlow]() - var knownCustomHomeServersUrls = [String]() - var isForceLoginFallbackEnabled = false -} diff --git a/RiotSwiftUI/Modules/Authentication/Common/Service/MatrixSDK/AuthenticationService.swift b/RiotSwiftUI/Modules/Authentication/Common/Service/MatrixSDK/AuthenticationService.swift index ba2c1888e..38021f43e 100644 --- a/RiotSwiftUI/Modules/Authentication/Common/Service/MatrixSDK/AuthenticationService.swift +++ b/RiotSwiftUI/Modules/Authentication/Common/Service/MatrixSDK/AuthenticationService.swift @@ -178,6 +178,7 @@ class AuthenticationService: NSObject { let homeserverAddress = HomeserverAddress.sanitized(homeserverAddress) guard var homeserverURL = URL(string: homeserverAddress) else { + MXLog.error("[AuthenticationService] Unable to create a URL from the supplied homeserver address when calling loginFlow.") throw AuthenticationError.invalidHomeserver } @@ -203,7 +204,10 @@ class AuthenticationService: NSObject { /// This method is used to get the flows for a server after a soft-logout. /// - Parameter session: The MXSession where a soft-logout has occurred. private func loginFlow(for session: MXSession) async throws -> LoginFlowResult { - guard let client = session.matrixRestClient else { throw AuthenticationError.missingMXRestClient } + guard let client = session.matrixRestClient else { + MXLog.error("[AuthenticationService] loginFlow called on a session that doesn't have a matrixRestClient.") + throw AuthenticationError.missingMXRestClient + } let state = AuthenticationState(flow: .login, homeserverAddress: client.homeserver) let loginFlow = try await getLoginFlowResult(client: session.matrixRestClient) diff --git a/RiotSwiftUI/Modules/Authentication/Common/Service/MatrixSDK/RegistrationModels.swift b/RiotSwiftUI/Modules/Authentication/Common/Service/MatrixSDK/RegistrationModels.swift index e234aa26f..d3ca60c0b 100644 --- a/RiotSwiftUI/Modules/Authentication/Common/Service/MatrixSDK/RegistrationModels.swift +++ b/RiotSwiftUI/Modules/Authentication/Common/Service/MatrixSDK/RegistrationModels.swift @@ -47,6 +47,7 @@ struct RegistrationParameters: Codable { let jsonData = try JSONEncoder().encode(self) let object = try JSONSerialization.jsonObject(with: jsonData) guard let dictionary = object as? [String: Any] else { + MXLog.error("[RegistrationParameters] dictionary: Unexpected type decoded \(type(of: object)). Expected a Dictionary.") throw AuthenticationError.dictionaryError } diff --git a/RiotSwiftUI/Modules/Authentication/Common/Service/MatrixSDK/RegistrationWizard.swift b/RiotSwiftUI/Modules/Authentication/Common/Service/MatrixSDK/RegistrationWizard.swift index 44dcd6c31..1315f2101 100644 --- a/RiotSwiftUI/Modules/Authentication/Common/Service/MatrixSDK/RegistrationWizard.swift +++ b/RiotSwiftUI/Modules/Authentication/Common/Service/MatrixSDK/RegistrationWizard.swift @@ -81,6 +81,7 @@ class RegistrationWizard { } catch { // Map M_FORBIDDEN into a registration error. guard let mxError = MXError(nsError: error), mxError.errcode == kMXErrCodeStringForbidden else { throw error } + MXLog.warning("[RegistrationWizard] Registration is disabled for the selected server.") throw RegistrationError.registrationDisabled } } @@ -112,6 +113,7 @@ class RegistrationWizard { /// - Parameter response: The response from ReCaptcha func performReCaptcha(response: String) async throws -> RegistrationResult { guard let session = state.currentSession else { + MXLog.error("[RegistrationWizard] performReCaptcha: Missing authentication session, createAccount hasn't been called.") throw RegistrationError.createAccountNotCalled } @@ -122,6 +124,7 @@ class RegistrationWizard { /// Perform the "m.login.terms" stage. func acceptTerms() async throws -> RegistrationResult { guard let session = state.currentSession else { + MXLog.error("[RegistrationWizard] acceptTerms: Missing authentication session, createAccount hasn't been called.") throw RegistrationError.createAccountNotCalled } @@ -132,6 +135,7 @@ class RegistrationWizard { /// Perform the "m.login.dummy" stage. func dummy() async throws -> RegistrationResult { guard let session = state.currentSession else { + MXLog.error("[RegistrationWizard] dummy: Missing authentication session, createAccount hasn't been called.") throw RegistrationError.createAccountNotCalled } @@ -151,6 +155,7 @@ class RegistrationWizard { /// Ask the homeserver to send again the current threePID (email or msisdn). func sendAgainThreePID() async throws -> RegistrationResult { guard let threePID = state.currentThreePIDData?.threePID else { + MXLog.error("[RegistrationWizard] sendAgainThreePID: Missing authentication session, createAccount hasn't been called.") throw RegistrationError.createAccountNotCalled } return try await sendThreePID(threePID: threePID) @@ -168,6 +173,7 @@ class RegistrationWizard { func checkIfEmailHasBeenValidated(delay: TimeInterval) async throws -> RegistrationResult { MXLog.failure("The delay on this method is no longer available. Move this to the object handling the polling.") guard let parameters = state.currentThreePIDData?.registrationParameters else { + MXLog.error("[RegistrationWizard] checkIfEmailHasBeenValidated: The current 3pid data hasn't been stored in the state.") throw RegistrationError.missingThreePIDData } @@ -178,10 +184,12 @@ class RegistrationWizard { private func validateThreePid(code: String) async throws -> RegistrationResult { guard let threePIDData = state.currentThreePIDData else { + MXLog.error("[RegistrationWizard] validateThreePid: There is no third party ID data stored in the state.") throw RegistrationError.missingThreePIDData } guard let submitURL = threePIDData.registrationResponse.submitURL else { + MXLog.error("[RegistrationWizard] validateThreePid: The third party ID data doesn't contain a submitURL.") throw RegistrationError.missingThreePIDURL } @@ -192,9 +200,11 @@ class RegistrationWizard { #warning("Seems odd to pass a nil baseURL and then the url as the path, yet this is how MXK3PID works") guard let httpClient = MXHTTPClient(baseURL: nil, andOnUnrecognizedCertificateBlock: nil) else { + MXLog.error("[RegistrationWizard] validateThreePid: Failed to create an MXHTTPClient.") throw RegistrationError.threePIDClientFailure } guard try await httpClient.validateThreePIDCode(submitURL: submitURL, validationBody: validationBody) else { + MXLog.error("[RegistrationWizard] validateThreePid: Third party ID validation failed.") throw RegistrationError.threePIDValidationFailure } @@ -205,6 +215,7 @@ class RegistrationWizard { private func sendThreePID(threePID: RegisterThreePID) async throws -> RegistrationResult { guard let session = state.currentSession else { + MXLog.error("[RegistrationWizard] sendThreePID: Missing authentication session, createAccount hasn't been called.") throw RegistrationError.createAccountNotCalled }