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

Emailpassword send reset password email #481

Merged
merged 113 commits into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from 112 commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
453e018
Rollback Dart_WeakHandle finalizer hack
nielsenko Mar 14, 2022
8430d42
Use dart main/flutter beta in github actions.
nielsenko Mar 22, 2022
e847de2
Add dart specific support for realm_http_transport_new
nielsenko Mar 16, 2022
6a5c9c4
Wire up realm_core
nielsenko Mar 18, 2022
fca9182
Apply suggestions from code review
nielsenko Mar 28, 2022
435e484
Copy all info from realm_http_request before starting async request
nielsenko Mar 28, 2022
d7207d9
Added ApplicationConfiguration
nielsenko Mar 18, 2022
ea8d7ef
Added Application class with async logIn method (includes stubs for U…
nielsenko Mar 25, 2022
b4eaf29
Implement email/password provider
desistefanova Mar 30, 2022
5e887a0
Implement RegisterUser in Application emailPasswordProvider
desistefanova Mar 31, 2022
b034700
test commented
desistefanova Mar 31, 2022
44625d4
CHANGELOG.md
desistefanova Mar 31, 2022
a54b1a8
Use common GCHandle class for userdata on all callbacks
nielsenko Mar 30, 2022
6ae70e2
Support hard gc handles as well, as suggested by Yavor. Ie. handles t…
nielsenko Apr 7, 2022
c81e0c0
Backport to dart 2.16 where we have to work around a finalization iss…
nielsenko Apr 1, 2022
6899dc8
Add support for http_transport
nielsenko Mar 18, 2022
9a17d45
Added ApplicationConfiguration
nielsenko Mar 18, 2022
73e2e4c
Update docs on public interface
nielsenko Apr 7, 2022
0baa62f
Address PR feedback
nielsenko Apr 11, 2022
20e95af
Added Application class with async logIn method (includes stubs for U…
nielsenko Apr 8, 2022
d63f205
Add testWithBass function
nielsenko Apr 8, 2022
0cdf4b7
Merge branch 'master' into realm_app_config
desistefanova Apr 11, 2022
b9cc163
Update CHANGELOG.md
desistefanova Apr 11, 2022
8448ffd
Merge branch 'realm_app_config' into realm_app
desistefanova Apr 11, 2022
7ff02ef
Commit after merge
desistefanova Apr 11, 2022
fc5e481
Fixes after merge
desistefanova Apr 11, 2022
c1cb35e
Merge branch 'realm_app'
desistefanova Apr 12, 2022
e07be97
Fixes after merge
desistefanova Apr 12, 2022
b7ddc96
Remove user and login
desistefanova Apr 12, 2022
938a168
size of handles
desistefanova Apr 12, 2022
d447fe0
Set size of handles
desistefanova Apr 12, 2022
ef644c5
workflow chanel = stable
desistefanova Apr 12, 2022
a132bf4
Delete realm_dart_http_transport
desistefanova Apr 12, 2022
4e15ea7
remove import dart:async from tests
desistefanova Apr 12, 2022
c453fde
Merge branch 'master' into realm_app
desistefanova Apr 12, 2022
348ed3e
Fixes after merge
desistefanova Apr 12, 2022
2778ff2
Fix after merge
desistefanova Apr 12, 2022
b26fc19
Merge branch 'realm_app' into auth_provider_register_email
desistefanova Apr 12, 2022
de08be0
Fix after merge
desistefanova Apr 12, 2022
a359038
Merge branch 'master' into realm_app
desistefanova Apr 12, 2022
792589b
Merge branch 'realm_app' into login_user
desistefanova Apr 12, 2022
6f28a22
Fix after merge
desistefanova Apr 12, 2022
1489eee
Merge branch 'master' into realm_app
desistefanova Apr 12, 2022
9fd8fec
Fix after merge
desistefanova Apr 12, 2022
07be0ae
Fix after merge
desistefanova Apr 12, 2022
b85cbb4
Merge branch 'realm_app' into login_user
desistefanova Apr 12, 2022
18ec3ca
Updarte CHANGELOG.md
desistefanova Apr 12, 2022
a69d013
Merge branch 'master' into login_user
blagoev Apr 13, 2022
60b665c
fix build
blagoev Apr 13, 2022
4e26d96
rename method
blagoev Apr 13, 2022
b94d62c
fix login invocation
blagoev Apr 13, 2022
bad719b
fix GC hints
blagoev Apr 13, 2022
333b99d
[test] build in debug
blagoev Apr 13, 2022
16d60f2
Merge branch 'master' into auth_provider_register_email
desistefanova Apr 13, 2022
3083650
Fix after merge
desistefanova Apr 13, 2022
2603ef6
Callback implementation changes
desistefanova Apr 13, 2022
2490fe4
Remove tests
desistefanova Apr 13, 2022
9e990c2
Delete old file
desistefanova Apr 14, 2022
17be615
Delete old files
desistefanova Apr 14, 2022
e8aa395
application holds the HttpTransport, AppConfig and SyncClient handles
blagoev Apr 17, 2022
5f3ace8
Merge branch 'master' into login_user
blagoev Apr 17, 2022
6d3e1bf
Merge branch 'master' into auth_provider_register_email
blagoev Apr 19, 2022
3c74ed6
move and rename EmailPassword class
blagoev Apr 19, 2022
47f48a9
EmailPasswordAuthProvider as standalone class
blagoev Apr 19, 2022
fedba5a
support EmailPassword confirm user
blagoev Apr 19, 2022
9f2fb6d
update changelog
blagoev Apr 19, 2022
e389fc1
support resend user confirm
blagoev Apr 19, 2022
d3f06ee
update changelog
blagoev Apr 19, 2022
6f445d5
support reset password
blagoev Apr 19, 2022
5e91ea9
update changelog
blagoev Apr 19, 2022
6cc233b
fix type in changelog
blagoev Apr 19, 2022
53393ea
support reset password email
blagoev Apr 19, 2022
17d6baf
update changelog
blagoev Apr 19, 2022
9fc1e1b
support weak and persistent handles
blagoev Apr 20, 2022
0ed9ada
add api doc
blagoev Apr 20, 2022
a94f222
add user api doc
blagoev Apr 20, 2022
ab1f03e
revert build type for linux
blagoev Apr 20, 2022
bcbc522
add ctor api doc
blagoev Apr 20, 2022
d8effa6
remove dead arg
blagoev Apr 20, 2022
188cf97
expose correct class,
blagoev Apr 20, 2022
4b0afec
fix build
blagoev Apr 20, 2022
588fe1d
Merge branch 'login_user' into auth_provider_register_email
blagoev Apr 20, 2022
c8848bf
use persistent handle for register user call
blagoev Apr 20, 2022
577b79f
await inside realm_core login
blagoev Apr 21, 2022
59ef6cd
revert to non async method
blagoev Apr 21, 2022
e3e6278
Merge branch 'auth_provider_register_email' into emailpassword-confir…
blagoev Apr 21, 2022
3438f38
use persistent handle
blagoev Apr 21, 2022
5a1523e
use named arg
blagoev Apr 21, 2022
ef5e89d
rename methods
blagoev Apr 21, 2022
8c0deb4
use string skip if url not present in test env
blagoev Apr 21, 2022
b37247d
move creation of httpTransportHandle, appConfigHandle and sycnClientC…
blagoev Apr 21, 2022
9c7127d
rename TO BAAS
blagoev Apr 21, 2022
7cc27d0
rename to BAAS
blagoev Apr 21, 2022
ec217bb
use non async login method
blagoev Apr 21, 2022
6392968
set skip to error if url is null
blagoev Apr 21, 2022
912e7f2
Merge branch 'login_user' into auth_provider_register_email
blagoev Apr 21, 2022
7bc1377
Merge branch 'auth_provider_register_email' into emailpassword-confir…
blagoev Apr 21, 2022
3457d72
Merge branch 'emailpassword-confirm-user' into emailpassword-resend-c…
blagoev Apr 21, 2022
5039965
use persistent handle
blagoev Apr 21, 2022
6c3205a
Merge branch 'emailpassword-resend-confirm' into emailpassword-reset-…
blagoev Apr 21, 2022
3196b88
use persistent handle
blagoev Apr 21, 2022
2507a00
fix
blagoev Apr 21, 2022
5d1ce11
Merge branch 'auth_provider_register_email' into emailpassword-confir…
blagoev Apr 21, 2022
6edb7a0
Merge branch 'emailpassword-confirm-user' into emailpassword-resend-c…
blagoev Apr 21, 2022
0e1e870
Merge branch 'emailpassword-resend-confirm' into emailpassword-reset-…
blagoev Apr 21, 2022
46a1dbb
remove dead file
blagoev Apr 21, 2022
622ad31
remove dead file
blagoev Apr 21, 2022
892d9c1
remove dead code
blagoev Apr 21, 2022
0f8e85a
Merge branch 'emailpassword-confirm-user' into emailpassword-resend-c…
blagoev Apr 21, 2022
e465edc
Merge branch 'emailpassword-resend-confirm' into emailpassword-reset-…
blagoev Apr 21, 2022
9194521
Merge branch 'emailpassword-reset-password' into emailpassword-send-r…
blagoev Apr 21, 2022
3aaf397
use persistent handle
blagoev Apr 21, 2022
aaec53a
Merge branch 'master' into emailpassword-send-reset-password-email
blagoev Apr 22, 2022
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
14 changes: 10 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,21 @@ x.x.x Release notes (yyyy-MM-dd)

### Enhancements
* Added a property `Configuration.disableFormatUpgrade`. When set to `true`, opening a Realm with an older file format will throw an exception to avoid automatically upgrading it. ([#310](https://github.com/realm/realm-dart/pull/310))
* Support result value from write transaction callbacks. ([#294](https://github.com/realm/realm-dart/pull/294/))
* Support result value from write transaction callbacks. ([#294](https://github.com/realm/realm-dart/pull/294))
* Added a property `Realm.isInTransaction` that indicates whether the Realm instance has an open write transaction associated with it.
* Support anonymous application credentials. ([#443](https://github.com/realm/realm-dart/pull/443/))
* Support anonymous application credentials. ([#443](https://github.com/realm/realm-dart/pull/443))
* Added a property `Configuration.initialDataCallback`. This is a callback executed when a Realm file is first created and allows you to populate some initial data necessary for your application. ([#298](https://github.com/realm/realm-dart/issues/298))
* Support application configuration. ([#306](https://github.com/realm/realm-dart/pull/306/))
* Support application class. ([#446](https://github.com/realm/realm-dart/pull/446/))
* Support application configuration. ([#306](https://github.com/realm/realm-dart/pull/306))
* Support application class. ([#446](https://github.com/realm/realm-dart/pull/446))
* Support should realm compact on open callback `Configuration.shouldCompactCallback` as option when configuring a Realm to determine if it should be compacted before being returned. ([#466](https://github.com/realm/realm-dart/pull/466/))
* 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 EmailPassword register user. ([#452](https://github.com/realm/realm-dart/pull/452))
* Support EmailPassword confirm user. ([#478](https://github.com/realm/realm-dart/pull/478))
* Support EmailPassword resend user confirmation email. ([#479](https://github.com/realm/realm-dart/pull/479))
* Support EmailPassword complete reset password. ([#480](https://github.com/realm/realm-dart/pull/480))
* Support EmailPassword reset password. ([#481](https://github.com/realm/realm-dart/pull/481))

### 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
16 changes: 15 additions & 1 deletion lib/src/application.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
import 'dart:io';
import 'package:meta/meta.dart';
import 'native/realm_core.dart';
import 'credentials.dart';
import 'user.dart';
import 'configuration.dart';

/// Specify if and how to persists user objects.
/// {@category Application}
enum MetadataPersistenceMode {
/// Persist [User] objects, but do not encrypt them.
plaintext,
Expand All @@ -36,6 +39,7 @@ enum MetadataPersistenceMode {
@immutable

/// A class exposing configuration options for an [Application]
/// {@category Application}
class ApplicationConfiguration {
/// The [appId] is the unique id that identifies the Realm application.
final String appId;
Expand Down Expand Up @@ -108,13 +112,23 @@ class ApplicationConfiguration {
/// The [Application]] can be used to
/// * Register uses and perform various user-related operations through authentication providers
/// * Synchronize data between the local device and a remote Realm App with Synchronized Realms
/// {@category Application}
class Application {
final AppHandle _handle;
final ApplicationConfiguration configuration;

Application(this.configuration) : _handle = realmCore.getApp(configuration);
/// Create an app with a particular [AppConfiguration]
Application(this.configuration) :
_handle = realmCore.getApp(configuration);

/// Logs in a user with the given credentials.
Future<User> logIn(Credentials credentials) async {
var userHandle = await realmCore.logIn(this, credentials);
return UserInternal.create(userHandle);
}
}

/// @nodoc
extension ApplicationInternal on Application {
AppHandle get handle => _handle;
}
54 changes: 48 additions & 6 deletions lib/src/credentials.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////

import 'native/realm_core.dart';
import 'application.dart';

/// An enum containing all authentication providers. These have to be enabled manually for the application before they can be used.
/// [Authentication Providers Docs](https://docs.mongodb.com/realm/authentication/providers/)
/// {@category Application}
enum AuthProvider {
/// Mechanism for authenticating without credentials.
enum AuthProviderType {
/// For authenticating without credentials.
anonymous,

/// Mechanism for authenticating with an email and a password.
/// For authenticating with an email and a password.
emailPassword,
}

Expand All @@ -33,24 +35,64 @@ enum AuthProvider {
class Credentials {
late final RealmAppCredentialsHandle _handle;

final AuthProvider provider;
final AuthProviderType provider;

/// Returns a [Credentials] object that can be used to authenticate an anonymous user.
/// [Anonymous Authentication Docs](https://docs.mongodb.com/realm/authentication/anonymous)
Credentials.anonymous()
: _handle = realmCore.createAppCredentialsAnonymous(),
provider = AuthProvider.anonymous;
provider = AuthProviderType.anonymous;

/// Returns a [Credentials] object that can be used to authenticate a user with their email and password.
/// A user can login with email and password only after they have registered their account and verified their
/// email.
/// [Email/Password Authentication Docs](https://docs.mongodb.com/realm/authentication/email-password)
Credentials.emailPassword(String email, String password)
: _handle = realmCore.createAppCredentialsEmailPassword(email, password),
provider = AuthProvider.emailPassword;
provider = AuthProviderType.emailPassword;
}

/// @nodoc
extension CredentialsInternal on Credentials {
RealmAppCredentialsHandle get handle => _handle;
}

/// A class, encapsulating functionality for users, logged in with [Credentials.emailPassword()].
/// It is always scoped to a particular app.
/// {@category Application}
class EmailPasswordAuthProvider {
final Application application;

/// Create a new EmailPasswordAuthProvider for the [application]
EmailPasswordAuthProvider(this.application);

/// Registers a new user with the given email and password.
/// The [email] to register with. This will be the user's username and, if user confirmation is enabled, this will be the address for
/// the confirmation email.
/// 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<void> 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<void> confirmUser(String token, String tokenId) {
return realmCore.emailPasswordConfirmUser(application, token, tokenId);
}

/// Resends the confirmation email for a user to the given email.
Future<void> resendUserConfirmation(String email) {
return realmCore.emailPasswordResendUserConfirmation(application, email);
}

/// Completes the reset password procedure by providing the desired new password.
Future<void> completeResetPassword(String password, String token, String tokenId) {
return realmCore.emailPasswordCompleteResetPassword(application, password, token, tokenId);
}

/// Sends a password reset email.
Future<void> resetPassword(String email) {
return realmCore.emailPasswordResetPassword(application, email);
}
}
62 changes: 52 additions & 10 deletions lib/src/native/realm_bindings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7449,34 +7449,76 @@ class RealmLibrary {
late final _realm_delete_finalizable = _realm_delete_finalizablePtr
.asFunction<void Function(Dart_FinalizableHandle, Object)>();

ffi.Pointer<ffi.Void> object_to_gc_handle(
ffi.Pointer<ffi.Void> object_to_weak_handle(
Object handle,
) {
return _object_to_gc_handle(
return _object_to_weak_handle(
handle,
);
}

late final _object_to_gc_handlePtr =
late final _object_to_weak_handlePtr =
_lookup<ffi.NativeFunction<ffi.Pointer<ffi.Void> Function(ffi.Handle)>>(
'object_to_gc_handle');
late final _object_to_gc_handle = _object_to_gc_handlePtr
'object_to_weak_handle');
late final _object_to_weak_handle = _object_to_weak_handlePtr
.asFunction<ffi.Pointer<ffi.Void> Function(Object)>();

Object gc_handle_to_object(
Object weak_handle_to_object(
ffi.Pointer<ffi.Void> handle,
) {
return _gc_handle_to_object(
return _weak_handle_to_object(
handle,
);
}

late final _gc_handle_to_objectPtr =
late final _weak_handle_to_objectPtr =
_lookup<ffi.NativeFunction<ffi.Handle Function(ffi.Pointer<ffi.Void>)>>(
'gc_handle_to_object');
late final _gc_handle_to_object = _gc_handle_to_objectPtr
'weak_handle_to_object');
late final _weak_handle_to_object = _weak_handle_to_objectPtr
.asFunction<Object Function(ffi.Pointer<ffi.Void>)>();

ffi.Pointer<ffi.Void> object_to_persistent_handle(
Object handle,
) {
return _object_to_persistent_handle(
handle,
);
}

late final _object_to_persistent_handlePtr =
_lookup<ffi.NativeFunction<ffi.Pointer<ffi.Void> Function(ffi.Handle)>>(
'object_to_persistent_handle');
late final _object_to_persistent_handle = _object_to_persistent_handlePtr
.asFunction<ffi.Pointer<ffi.Void> Function(Object)>();

Object persistent_handle_to_object(
ffi.Pointer<ffi.Void> handle,
) {
return _persistent_handle_to_object(
handle,
);
}

late final _persistent_handle_to_objectPtr =
_lookup<ffi.NativeFunction<ffi.Handle Function(ffi.Pointer<ffi.Void>)>>(
'persistent_handle_to_object');
late final _persistent_handle_to_object = _persistent_handle_to_objectPtr
.asFunction<Object Function(ffi.Pointer<ffi.Void>)>();

void delete_persistent_handle(
ffi.Pointer<ffi.Void> handle,
) {
return _delete_persistent_handle(
handle,
);
}

late final _delete_persistent_handlePtr =
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>)>>(
'delete_persistent_handle');
late final _delete_persistent_handle = _delete_persistent_handlePtr
.asFunction<void Function(ffi.Pointer<ffi.Void>)>();

ffi.Pointer<realm_scheduler_t> realm_dart_create_scheduler(
int isolateId,
int port,
Expand Down
Loading