Handle waiting list error. (#1165)

This commit is contained in:
Doug
2023-06-26 18:26:20 +01:00
committed by GitHub
parent bc7faec44a
commit 2fce96d540
25 changed files with 589 additions and 19 deletions
@@ -102,13 +102,13 @@ class AuthenticationServiceProxy: AuthenticationServiceProxyProtocol {
// }
}
func login(username: String, password: String, initialDeviceName: String?, deviceId: String?) async -> Result<UserSessionProtocol, AuthenticationServiceError> {
func login(username: String, password: String, initialDeviceName: String?, deviceID: String?) async -> Result<UserSessionProtocol, AuthenticationServiceError> {
do {
let client = try await Task.dispatch(on: .global()) {
try self.authenticationService.login(username: username,
password: password,
initialDeviceName: initialDeviceName,
deviceId: deviceId)
deviceId: deviceID)
}
return await userSession(for: client)
@@ -116,6 +116,10 @@ class AuthenticationServiceProxy: AuthenticationServiceProxyProtocol {
MXLog.error("Failed logging in with error: \(error)")
guard let error = error as? AuthenticationError else { return .failure(.failedLoggingIn) }
if error.isElementWaitlist {
return .failure(.isOnWaitlist)
}
switch error.code {
case .forbidden:
return .failure(.invalidCredentials)
@@ -34,6 +34,8 @@ enum AuthenticationServiceError: Error {
case slidingSyncNotAvailable
case accountDeactivated
case failedLoggingIn
case isOnWaitlist
}
protocol AuthenticationServiceProxyProtocol {
@@ -47,7 +49,7 @@ protocol AuthenticationServiceProxyProtocol {
/// Add docs.
func loginWithOIDCCallback(_ callbackURL: URL, data: OIDCAuthenticationDataProxy) async -> Result<UserSessionProtocol, AuthenticationServiceError>
/// Performs a password login using the current homeserver.
func login(username: String, password: String, initialDeviceName: String?, deviceId: String?) async -> Result<UserSessionProtocol, AuthenticationServiceError>
func login(username: String, password: String, initialDeviceName: String?, deviceID: String?) async -> Result<UserSessionProtocol, AuthenticationServiceError>
}
// MARK: - OIDC
@@ -56,7 +56,7 @@ class MockAuthenticationServiceProxy: AuthenticationServiceProxyProtocol {
.failure(.oidcError(.notSupported))
}
func login(username: String, password: String, initialDeviceName: String?, deviceId: String?) async -> Result<UserSessionProtocol, AuthenticationServiceError> {
func login(username: String, password: String, initialDeviceName: String?, deviceID: String?) async -> Result<UserSessionProtocol, AuthenticationServiceError> {
// Login only succeeds if the username and password match the valid credentials property
guard username == validCredentials.username, password == validCredentials.password else {
return .failure(.invalidCredentials)