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

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

Open
1 of 2 tasks
cbush opened this issue Oct 3, 2019 · 0 comments
Open
1 of 2 tasks

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

cbush opened this issue Oct 3, 2019 · 0 comments
Labels

Comments

@cbush
Copy link

cbush commented Oct 3, 2019

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: ?
@cbush cbush added the T-Bug label Oct 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant