Skip to content
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

support remove user #492

Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. ([#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))
Expand Down
5 changes: 5 additions & 0 deletions lib/src/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> removeUser(User user) async {
return await realmCore.removeUser(this, user);
}
}

/// @nodoc
Expand Down
14 changes: 14 additions & 0 deletions lib/src/native/realm_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,20 @@ class _RealmCore {
return userHandles;
});
}

Future<void> removeUser(App app, User user) async {
final completer = Completer<void>();
_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 {
Expand Down