Skip to content

Fixed crash in Realm.deleteFile, Realm.exists, Realm.schemaVersion, Realm.determinePath, Realm.transformConfig and User#isLoggedIn #6662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* None

### Fixed
* Fixed a crash experienced on React Native when accessing `Realm.deleteFile`, `Realm.exists`, `Realm.schemaVersion`, `Realm.determinePath`, `Realm.transformConfig` and `User#isLoggedIn`. ([PR #6662](https://github.com/realm/realm-js/pull/6662), since v12.8.0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Fixed a crash experienced on React Native when accessing `Realm.deleteFile`, `Realm.exists`, `Realm.schemaVersion`, `Realm.determinePath`, `Realm.transformConfig` and `User#isLoggedIn`. ([PR #6662](https://github.com/realm/realm-js/pull/6662), since v12.8.0)
* Fixed a crash experienced on React Native when accessing `Realm.deleteFile`, `Realm.exists`, `Realm.schemaVersion`, `Realm.determinePath`, `Realm.transformConfig` and `User#isLoggedIn`. ([#6662](https://github.com/realm/realm-js/pull/6662), since v12.8.0)

* <How to hit and notice issue? what was the impact?> ([#????](https://github.com/realm/realm-js/issues/????), since v?.?.?)
* None

### Compatibility
* React Native >= v0.71.4
Expand Down
5 changes: 3 additions & 2 deletions packages/realm/bindgen/js_opt_in_spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ classes:
- make_ssl_verify_callback
- needs_file_format_upgrade
- sync_user_as_app_user
- app_user_as_sync_user

LogCategoryRef:
methods:
Expand Down Expand Up @@ -446,7 +447,8 @@ classes:
- api_key

SyncUser:
methods: []
methods:
- is_logged_in

User:
methods:
Expand All @@ -459,7 +461,6 @@ classes:
- unsubscribe
- path_for_realm
- app
- is_logged_in
- user_id
- app_id
- legacy_identities
Expand Down
5 changes: 4 additions & 1 deletion packages/realm/src/app-services/SyncConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,11 @@ export function toBindingSyncConfig(config: SyncConfiguration): binding.SyncConf
proxyConfig,
} = config;

const syncUser = binding.Helpers.appUserAsSyncUser(user.internal);
assert(syncUser);

return {
user: user.internal,
user: syncUser,
partitionValue: flexible ? undefined : EJSON.stringify(partitionValue),
flxSyncRequested: !!flexible,
stopPolicy: _sessionStopPolicy
Expand Down
4 changes: 3 additions & 1 deletion packages/realm/src/app-services/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ export class User<
* @returns `true` if the user is logged in, `false` otherwise.
*/
get isLoggedIn(): boolean {
return this.internal.isLoggedIn;
const syncUser = binding.Helpers.appUserAsSyncUser(this.internal);
assert(syncUser);
return syncUser.isLoggedIn;
}

/**
Expand Down
Loading