Skip to content

Commit

Permalink
Create custom error code for InvalidPassword response (#4851)
Browse files Browse the repository at this point in the history
  • Loading branch information
jedelbo authored Aug 18, 2021
1 parent 050fe6a commit bc53af9
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Enhancements
* InstructionApplier exceptions now contain information about what object/changeset was being applied when the exception was thrown. ([#4836](https://github.com/realm/realm-core/issues/4836))
* Added ServiceErrorCode for wrong username/password. ([#4581](https://github.com/realm/realm-core/issues/4581))
* Query parser now accepts "BETWEEN" operator. Can be used like "Age BETWEEN {20, 60}" which means "'Age' must be in the open interval ]20;60[".

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion how-to-build.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ To run the [app] tests against the local image, you need to configure a build wi
```
mkdir build.sync.ninja
cmake -B build.sync.ninja -G Ninja -DREALM_ENABLE_AUTH_TESTS=1 -DREALM_MONGODB_ENDPOINT=http://localhost:9090
cmake --build build.sync.ninja --target tests
cmake --build build.sync.ninja --target realm-object-store-tests
./build.sync.ninja/test/object-store/realm-object-store-tests -d=1
```
### Developing inside a container
Expand Down
1 change: 1 addition & 0 deletions src/realm/object-store/sync/generic_network_transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ static const std::map<std::string, ServiceErrorCode> service_error_map = {
{"AuthError", ServiceErrorCode::auth_error},
{"BadRequest", ServiceErrorCode::bad_request},
{"AccountNameInUse", ServiceErrorCode::account_name_in_use},
{"InvalidPassword", ServiceErrorCode::invalid_email_password},
{"Unknown", ServiceErrorCode::unknown},
};

Expand Down
1 change: 1 addition & 0 deletions src/realm/object-store/sync/generic_network_transport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ enum class ServiceErrorCode {
auth_error = 47,
bad_request = 48,
account_name_in_use = 49,
invalid_email_password = 50,

unknown = -1,
none = 0
Expand Down
12 changes: 12 additions & 0 deletions test/object-store/sync/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,18 @@ TEST_CASE("app: UsernamePasswordProviderClient integration", "[sync][app]") {
CHECK(user->user_profile().email() == email);
}

SECTION("cannot login with wrong password") {
app->log_in_with_credentials(realm::app::AppCredentials::username_password(email, "boogeyman"),
[&](std::shared_ptr<realm::SyncUser> user, Optional<app::AppError> error) {
CHECK(!user);
REQUIRE(error);
REQUIRE(error->error_code.value() ==
int(ServiceErrorCode::invalid_email_password));
processed = true;
});
CHECK(processed);
}

SECTION("confirm user") {
app->provider_client<App::UsernamePasswordProviderClient>().confirm_user(
"a_token", "a_token_id", [&](Optional<app::AppError> error) {
Expand Down

0 comments on commit bc53af9

Please sign in to comment.