Getting "unauthorized" error instead of "confirmation required" when user hasn't confirmed email

I’m testing a scenario in which a user who tried to sign up with their email but never confirmed it then tries to log in. Previously the error I got in this case was “confirmation required”, but now instead I’m getting “unauthorized”. This happens whether I print the error itself or the localized description. Strangely though, in the server logs, it shows correctly as “confirmation required”. This creates a confusing user experience. I’ve even tried deleting and recreating the app service but I’m still getting the same behavior.

func attemptEmailLogIn() {
        updateCredentialsError(forExistingUser: true)
        if errorMessage == nil {
            Task {
                do {
                    let _ = try await app.login(credentials: Credentials.emailPassword(email: email, password: password))
                    userOnboardedAndLoggedIn = true
                } catch {
                    print("Error is \(error)") 
                    print("Failed to log in user: \(error.localizedDescription)")
                    if error.localizedDescription == "confirmation required" {
                        errorMessage = "Looks like you haven't confirmed yet. Check your spam folder and make sure your email address is correct"
                    } else if error.localizedDescription == "invalid username/password" {
                        errorMessage = "Your username or password is invalid"
                    } else {
                        errorMessage = error.localizedDescription
                    }
                }
            }
        }
    }

1 Like

I completely understand your frustration, and I want to help you get to the bottom of this. However, relying solely on localizedDescription might not give you the full picture, as it can vary significantly between different errors and may not provide the detailed insights needed to resolve the issue effectively.

To ensure you’re getting the most accurate diagnosis, I highly recommend opening a service ticket with all relevant details, including the exact time and date of the error. The Tech Services team can then pull the logs and pinpoint the exact issue. They’ll be able to tell you what’s happening behind the scenes and offer guidance on how to handle these errors more effectively.

If you’re unsure how to make these errors more descriptive or actionable, the support team can also provide advice on enhancing your error handling. Given that Realm’s error logs are often limited in detail, involving Tech Services (I’m a former TSE from MongoDB) is the best way to get a precise diagnosis and targeted solution.

In short, opening a support ticket with your Realm app ID and other relevant details will put you in the best position to get this resolved. The error you’re seeing could be due to a wide range of issues, and the support team will help you narrow it down and find the right fix.