Skip to content
This repository was archived by the owner on Nov 8, 2021. It is now read-only.
This repository was archived by the owner on Nov 8, 2021. It is now read-only.

"Invalid credential" error returned instead of "user already exists" #427

@cbush

Description

@cbush

Using username/password authentication to log in as an existing user with register == true, I get the "invalid credential" error code, not the "user already exists" error. Likewise, if I log in as a non-existent user with register == false, I get "invalid credential" instead of "user does not exist". Is this a bug?

I have checked that username/authentication is enabled on my instance and email validation is disabled. I can see that the users are being created the first time.

Goals

I would like to have special code to handle the case where the user already exists, but with the same error returned I can't distinguish this error from any other auth error.

Expected Results

userAlreadyExists error code (613)

Actual Results

invalidCredential error code (611)

Steps to Reproduce

  1. Log in (registering a new user)
  2. Log out
  3. Log in again as the same user (register still set to true)
  4. Handle error and check the code

Code Sample

let creds = SyncCredentials.usernamePassword(username: name, password: "password", register: true);

SyncUser.logIn(with: creds, server: Constants.AUTH_URL, onCompletion: { [weak self](user, err) in
    if let _ = user {
        // login successful
    } else if let error = err as? SyncAuthError {
        switch error.code {
            case .userDoesNotExist: // never hit!
                fatalError(error.localizedDescription);
            case .userAlreadyExists: // never hit!
                fatalError(error.localizedDescription);
            case .invalidCredential: // this is always the case
                fatalError(error.localizedDescription);
            default:
                break;
        }
        
    }
})

Version of Realm and Tooling

  • Realm Object Server Version: 3.26.2
  • Flavor:
    • Cloud
    • Self-hosted
  • Server OS & Version: ? (e.g. CentOS 6)
  • Client SDK Version: RealmSwift 3.16.2
  • Client OS & Version: ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions