Add a couple more error messages during authentication. (#2497)
* Add copy for error when signing in with refresh tokens enabled. * Show an error when a server's well-known file is invalid. * Changelog. * Fix wrong alert.
This commit is contained in:
@@ -112,8 +112,12 @@ final class LoginScreenCoordinator: CoordinatorProtocol {
|
||||
viewModel.displayError(.alert(L10n.screenLoginErrorInvalidCredentials))
|
||||
case .accountDeactivated:
|
||||
viewModel.displayError(.alert(L10n.screenLoginErrorDeactivatedAccount))
|
||||
case .invalidWellKnown(let error):
|
||||
viewModel.displayError(.invalidWellKnownAlert(error))
|
||||
case .slidingSyncNotAvailable:
|
||||
viewModel.displayError(.slidingSyncAlert)
|
||||
case .sessionTokenRefreshNotSupported:
|
||||
viewModel.displayError(.refreshTokenAlert)
|
||||
default:
|
||||
viewModel.displayError(.alert(L10n.errorUnknown))
|
||||
}
|
||||
|
||||
@@ -82,8 +82,12 @@ enum LoginScreenErrorType: Hashable {
|
||||
case alert(String)
|
||||
/// Looking up the homeserver from the username failed.
|
||||
case invalidHomeserver
|
||||
/// An alert that informs the user about a bad well-known file.
|
||||
case invalidWellKnownAlert(String)
|
||||
/// An alert that allows the user to learn about sliding sync.
|
||||
case slidingSyncAlert
|
||||
/// An alert that informs the user that login failed due to a refresh token being returned.
|
||||
case refreshTokenAlert
|
||||
/// The response from the homeserver was unexpected.
|
||||
case unknown
|
||||
}
|
||||
|
||||
@@ -66,6 +66,10 @@ class LoginScreenViewModel: LoginScreenViewModelType, LoginScreenViewModelProtoc
|
||||
state.bindings.alertInfo = AlertInfo(id: type,
|
||||
title: L10n.commonError,
|
||||
message: L10n.screenLoginErrorInvalidUserId)
|
||||
case .invalidWellKnownAlert(let error):
|
||||
state.bindings.alertInfo = AlertInfo(id: .slidingSyncAlert,
|
||||
title: L10n.commonServerNotSupported,
|
||||
message: L10n.screenChangeServerErrorInvalidWellKnown(error))
|
||||
case .slidingSyncAlert:
|
||||
let openURL = { UIApplication.shared.open(self.slidingSyncLearnMoreURL) }
|
||||
state.bindings.alertInfo = AlertInfo(id: .slidingSyncAlert,
|
||||
@@ -76,6 +80,10 @@ class LoginScreenViewModel: LoginScreenViewModelType, LoginScreenViewModelProtoc
|
||||
|
||||
// Clear out the invalid username to avoid an attempted login to matrix.org
|
||||
state.bindings.username = ""
|
||||
case .refreshTokenAlert:
|
||||
state.bindings.alertInfo = AlertInfo(id: type,
|
||||
title: L10n.commonServerNotSupported,
|
||||
message: L10n.screenLoginErrorRefreshTokens)
|
||||
case .unknown:
|
||||
state.bindings.alertInfo = AlertInfo(id: type)
|
||||
}
|
||||
|
||||
@@ -111,6 +111,8 @@ final class ServerSelectionScreenCoordinator: CoordinatorProtocol {
|
||||
switch error {
|
||||
case .invalidServer, .invalidHomeserverAddress:
|
||||
viewModel.displayError(.footerMessage(L10n.screenChangeServerErrorInvalidHomeserver))
|
||||
case .invalidWellKnown(let error):
|
||||
viewModel.displayError(.invalidWellKnownAlert(error))
|
||||
case .slidingSyncNotAvailable:
|
||||
viewModel.displayError(.slidingSyncAlert)
|
||||
default:
|
||||
|
||||
@@ -87,6 +87,8 @@ enum ServerSelectionScreenViewAction {
|
||||
enum ServerSelectionScreenErrorType: Hashable {
|
||||
/// An error message to be shown in the text field footer.
|
||||
case footerMessage(String)
|
||||
/// An alert that informs the user about a bad well-known file.
|
||||
case invalidWellKnownAlert(String)
|
||||
/// An alert that allows the user to learn about sliding sync.
|
||||
case slidingSyncAlert
|
||||
}
|
||||
|
||||
@@ -54,6 +54,10 @@ class ServerSelectionScreenViewModel: ServerSelectionScreenViewModelType, Server
|
||||
withElementAnimation {
|
||||
state.footerErrorMessage = message
|
||||
}
|
||||
case .invalidWellKnownAlert(let error):
|
||||
state.bindings.alertInfo = AlertInfo(id: .slidingSyncAlert,
|
||||
title: L10n.commonServerNotSupported,
|
||||
message: L10n.screenChangeServerErrorInvalidWellKnown(error))
|
||||
case .slidingSyncAlert:
|
||||
let openURL = { UIApplication.shared.open(self.slidingSyncLearnMoreURL) }
|
||||
state.bindings.alertInfo = AlertInfo(id: .slidingSyncAlert,
|
||||
|
||||
@@ -187,9 +187,7 @@ final class SoftLogoutScreenCoordinator: CoordinatorProtocol {
|
||||
// No need to show an error, the user cancelled authentication.
|
||||
break
|
||||
case .sessionTokenRefreshNotSupported:
|
||||
// We should display a specific error saying that we do not support this kind of login
|
||||
// But the copy is TBD
|
||||
viewModel.displayError(.alert(L10n.errorUnknown))
|
||||
viewModel.displayError(.refreshTokenAlert)
|
||||
default:
|
||||
viewModel.displayError(.alert(L10n.errorUnknown))
|
||||
}
|
||||
|
||||
@@ -101,6 +101,8 @@ enum SoftLogoutScreenViewAction {
|
||||
enum SoftLogoutScreenErrorType: Hashable {
|
||||
/// A specific error message shown in an alert.
|
||||
case alert(String)
|
||||
/// An alert that informs the user that login failed due to a refresh token being returned.
|
||||
case refreshTokenAlert
|
||||
/// An unknown error occurred.
|
||||
case unknown
|
||||
}
|
||||
|
||||
@@ -60,6 +60,10 @@ class SoftLogoutScreenViewModel: SoftLogoutScreenViewModelType, SoftLogoutScreen
|
||||
state.bindings.alertInfo = AlertInfo(id: type,
|
||||
title: L10n.commonError,
|
||||
message: message)
|
||||
case .refreshTokenAlert:
|
||||
state.bindings.alertInfo = AlertInfo(id: type,
|
||||
title: L10n.commonServerNotSupported,
|
||||
message: L10n.screenLoginErrorRefreshTokens)
|
||||
case .unknown:
|
||||
state.bindings.alertInfo = AlertInfo(id: type)
|
||||
}
|
||||
|
||||
@@ -80,6 +80,9 @@ class AuthenticationServiceProxy: AuthenticationServiceProxyProtocol {
|
||||
|
||||
homeserverSubject.send(homeserver)
|
||||
return .success(())
|
||||
} catch AuthenticationError.WellKnownDeserializationError(let error) {
|
||||
MXLog.error("The user entered a server with an invalid well-known file: \(error)")
|
||||
return .failure(.invalidWellKnown(error))
|
||||
} catch AuthenticationError.SlidingSyncNotAvailable {
|
||||
MXLog.info("User entered a homeserver that isn't configured for sliding sync.")
|
||||
return .failure(.slidingSyncNotAvailable)
|
||||
|
||||
@@ -31,6 +31,7 @@ enum AuthenticationServiceError: Error {
|
||||
case invalidServer
|
||||
case invalidCredentials
|
||||
case invalidHomeserverAddress
|
||||
case invalidWellKnown(String)
|
||||
case slidingSyncNotAvailable
|
||||
case accountDeactivated
|
||||
case failedLoggingIn
|
||||
|
||||
1
changelog.d/pr-2497.change
Normal file
1
changelog.d/pr-2497.change
Normal file
@@ -0,0 +1 @@
|
||||
Add error messages about refresh tokens and an invalid well-known file.
|
||||
Reference in New Issue
Block a user