diff --git a/CHANGELOG.md b/CHANGELOG.md index e089321b2..b5f6db4ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,8 @@ x.x.x Release notes (yyyy-MM-dd) * Support ObjectId type. ([#468](https://github.com/realm/realm-dart/pull/468)) * Support Uuid type. ([#470](https://github.com/realm/realm-dart/pull/470)) * Support application login. ([#469](https://github.com/realm/realm-dart/pull/469)) -* Support user registration with EmailPassword authentication provider. ([#452](https://github.com/realm/realm-dart/pull/452)) +* Support EmailPassword register user. ([#452](https://github.com/realm/realm-dart/pull/452)) +* Support EmailPassowrd confirm user. ([#478](https://github.com/realm/realm-dart/pull/478)) ### 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/credentials.dart b/lib/src/credentials.dart index 98eec4bc0..45ede1534 100644 --- a/lib/src/credentials.dart +++ b/lib/src/credentials.dart @@ -72,7 +72,12 @@ class EmailPasswordAuthProvider { /// The [password] to associate with the email. The password must be between 6 and 128 characters long. /// /// Successful completion indicates that the user has been created on the server and can now be logged in with [Credentials.emailPassword()]. - Future registerUser(String email, String password) async { - return realmCore.appEmailPasswordRegisterUser(application, email, password); + Future registerUser(String email, String password) { + return realmCore.emailPasswordRegisterUser(application, email, password); + } + + /// Confirms a user with the given token and token id. These are typically included in the registration email. + Future confirmUser(String token, String tokenId) { + return realmCore.emailPasswordConfirmUser(application, token, tokenId); } } diff --git a/lib/src/native/realm_core.dart b/lib/src/native/realm_core.dart index f0ca6f373..c9c0710a5 100644 --- a/lib/src/native/realm_core.dart +++ b/lib/src/native/realm_core.dart @@ -906,7 +906,7 @@ class _RealmCore { completer.complete(); } - Future appEmailPasswordRegisterUser(Application application, String email, String password) { + Future emailPasswordRegisterUser(Application application, String email, String password) { final completer = Completer(); using((arena) { _realmLib.invokeGetBool(() => _realmLib.realm_app_email_password_provider_client_register_email( @@ -920,6 +920,21 @@ class _RealmCore { }); return completer.future; } + + Future emailPasswordConfirmUser(Application application, String token, String tokenId) { + final completer = Completer(); + using((arena) { + _realmLib.invokeGetBool(() => _realmLib.realm_app_email_password_provider_client_confirm_user( + application.handle._pointer, + token.toUtf8Ptr(arena), + tokenId.toUtf8Ptr(arena), + Pointer.fromFunction(void_completion_callback), + completer.toPersistentHandle(), + _deletePersistentHandleFuncPtr, + )); + }); + return completer.future; + } } class LastError {