From 3fe824e848b7c2a35b4b2c44117acb78c85d08e6 Mon Sep 17 00:00:00 2001 From: blagoev Date: Sat, 23 Apr 2022 09:06:25 +0300 Subject: [PATCH 1/2] support remove user --- CHANGELOG.md | 1 + lib/src/app.dart | 5 +++++ lib/src/native/realm_core.dart | 14 ++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a61d66988..1583cd9bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ x.x.x Release notes (yyyy-MM-dd) * Support EmailPassword retry custom user confirmation functions. ([#484](https://github.com/realm/realm-dart/pull/484)) * Expose currentUser property on App. ([473](https://github.com/realm/realm-dart/pull/473)) * Support logout user. ([#476](https://github.com/realm/realm-dart/pull/476)) +* Support remove user. ([#](https://github.com/realm/realm-dart/pull/)) ### Fixed * Fixed an issue that would result in the wrong transaction being rolled back if you start a write transaction inside a write transaction. ([#442](https://github.com/realm/realm-dart/issues/442)) diff --git a/lib/src/app.dart b/lib/src/app.dart index 577d575a0..31147c100 100644 --- a/lib/src/app.dart +++ b/lib/src/app.dart @@ -151,6 +151,11 @@ class App { return await realmCore.logOut(this, user); } + + /// Removes a [user] and their local data from the device. If the user is logged in, they will be logged out in the process. + Future removeUser(User user) async { + return await realmCore.removeUser(this, user); + } } /// @nodoc diff --git a/lib/src/native/realm_core.dart b/lib/src/native/realm_core.dart index 6832b661f..45323b6fd 100644 --- a/lib/src/native/realm_core.dart +++ b/lib/src/native/realm_core.dart @@ -1078,6 +1078,20 @@ class _RealmCore { return userHandles; }); } + + Future removeUser(App app, User user) async { + final completer = Completer(); + _realmLib.invokeGetBool( + () => _realmLib.realm_app_remove_user( + app.handle._pointer, + user.handle._pointer, + Pointer.fromFunction(void_completion_callback), + completer.toPersistentHandle(), + _deletePersistentHandleFuncPtr, + ), + "Remove user failed"); + return completer.future; + } } class LastError { From b7bfac892aa95f20661be605c0b10ef4354a253a Mon Sep 17 00:00:00 2001 From: blagoev Date: Sat, 23 Apr 2022 23:57:41 +0300 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1583cd9bc..3138e7492 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,7 +27,7 @@ x.x.x Release notes (yyyy-MM-dd) * Support EmailPassword retry custom user confirmation functions. ([#484](https://github.com/realm/realm-dart/pull/484)) * Expose currentUser property on App. ([473](https://github.com/realm/realm-dart/pull/473)) * Support logout user. ([#476](https://github.com/realm/realm-dart/pull/476)) -* Support remove user. ([#](https://github.com/realm/realm-dart/pull/)) +* Support remove user. ([#492](https://github.com/realm/realm-dart/pull/492)) ### Fixed * Fixed an issue that would result in the wrong transaction being rolled back if you start a write transaction inside a write transaction. ([#442](https://github.com/realm/realm-dart/issues/442))