mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 15:45:11 +00:00
Handle waiting list error. (#1165)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user