diff --git a/Mlem/API/Models/APIErrorResponse.swift b/Mlem/API/Models/APIErrorResponse.swift index ba50e89b3..a015e9512 100644 --- a/Mlem/API/Models/APIErrorResponse.swift +++ b/Mlem/API/Models/APIErrorResponse.swift @@ -23,8 +23,15 @@ private let possible2FAErrors = [ "incorrect_totp_token" ] +private let registrationErrors = [ + "registration_application_pending", + "email_not_verified" +] + extension APIErrorResponse { var isIncorrectLogin: Bool { possibleCredentialErrors.contains(error) } var requires2FA: Bool { possible2FAErrors.contains(error) } var isNotLoggedIn: Bool { error == "not_logged_in" } + var userRegistrationPending: Bool { registrationErrors.contains(error) } + var emailNotVerified: Bool { registrationErrors.contains(error) } } diff --git a/Mlem/Views/Shared/Accounts/Add Account View.swift b/Mlem/Views/Shared/Accounts/Add Account View.swift index 126348af6..5a3c07eef 100644 --- a/Mlem/Views/Shared/Accounts/Add Account View.swift +++ b/Mlem/Views/Shared/Accounts/Add Account View.swift @@ -68,6 +68,8 @@ struct AddSavedInstanceView: View { : "Please check your username and password" } + var registrationError = "Please verify your email and try again." + init( onboarding: Bool, givenInstance: String? = nil @@ -379,6 +381,13 @@ struct AddSavedInstanceView: View { return case let APIClientError.response(errorResponse, _) where errorResponse.isIncorrectLogin: message = badCredentialsMessage + + case let APIClientError.response(errorResponse, _) where errorResponse.emailNotVerified: + message = registrationError + + case let APIClientError.response(errorResponse, _) where errorResponse.userRegistrationPending: + message = registrationError + default: // unhandled error encountered... message = "Something went wrong"