supabase/gotrue-dart

SignUp does not return Session/User object

Opened this issue · 1 comments

I have enabled Enable email confirmations.

When trying to SignUp a new user, not getting Session or User object. But based on this documentation
https://supabase.com/docs/reference/javascript/auth-signup (i know this is Javascript ref).

  • If "Email Confirmations" is turned on, a user is returned but session will be null.

Auth 'users' table is also showing the registered user.

Here is the code:
pubspec => supabase: ^0.2.14

final GotrueSessionResponse response = await _client.auth.signUp(email, pwd);
log('DATA : ${response.data?.toJson()}');

Result is NULL.

Thanks @krsikarya for opening this issue.

I was going to say we do have a dart documentation here, but found out that the dart doc also says the same thing If "Email Confirmations" is turned on, a user is returned but session will be null, which is not accurate, and I will submit a PR to fix it.

Currently with the Dart library, you will not receive user or session object when the email confirmation is turned on as you can see here. This is probably not the ideal behavior, so maybe we can discuss here how we can solve this.

We have discussed how to fix this in this issue before by separating the user object within GotrueSessionResponse like the following. @bdlukaa what do you think about this approach?

class GotrueSessionResponse extends GotrueResponse {
  Session? data;
  String? provider;
  String? url;
  User? user;

  GotrueSessionResponse({
    this.data,
    this.provider,
    this.url,
    User? user,
    GotrueError? error,
  }) : this.user = user ?? data?user,   super(error: error);
}