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

feat(gotrue): add reauthenticate and resend method #517

Merged
merged 7 commits into from
Jul 12, 2023

Conversation

Vinzent03
Copy link
Collaborator

@Vinzent03 Vinzent03 commented Jun 21, 2023

I've noticed gotrue-js contains the reauthenticate and resend method, but gotrue-dartdoes not.
gotrue-js pr for reauthenticate.

Though I'm very unsure about the parameter for resend. It uses different classes and enums for phone and email

@Vinzent03 Vinzent03 marked this pull request as ready for review June 22, 2023 21:20
@Vinzent03 Vinzent03 changed the title feat(gotrue): add reauthenticate method feat(gotrue): add reauthenticate and resend method Jun 28, 2023
Copy link
Member

@dshukertjr dshukertjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for the detailed check! The PR looks amazing! Just had one small thing that I missed earlier.

packages/gotrue/lib/src/gotrue_client.dart Outdated Show resolved Hide resolved
packages/gotrue/lib/src/types/user.dart Outdated Show resolved Hide resolved
@dshukertjr
Copy link
Member

Let's wait to merge this until we confirm with the gotrue-js team to see if the remove session thing was intentional or not.

kangmingtay pushed a commit to supabase/auth-js that referenced this pull request Jul 10, 2023
## What kind of change does this PR introduce?

Bug fix

## What is the current behavior?

When you call the `resend` method to e.g. resend an email to change your
email, you get logged out.

## What is the new behavior?

On email and phone change you don't get logged out.

## Additional context

I noticed this when implementing this method in gotrue-dart
supabase/supabase-flutter#517 (comment)
@Vinzent03
Copy link
Collaborator Author

@dshukertjr This can be merged now, right?

Copy link
Member

@dshukertjr dshukertjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉🚀

@dshukertjr dshukertjr merged commit 35a924b into main Jul 12, 2023
@dshukertjr dshukertjr deleted the feat/reauthenticate branch July 12, 2023 00:46
@haykodarb
Copy link

haykodarb commented Jul 23, 2023

Is it possible this stopped working due to changes in the backend?

I'm getting the following exception

AuthException(message: Missing one of these types: signup, email_change, sms, phone_change, statusCode: 400)

when using

static Future<BackendResponse> resendEmail({required String email}) async {
    try {
      final SupabaseClient client = Supabase.instance.client;

      final ResendResponse response = await client.auth.resend(
        type: OtpType.email,
        email: email,
      );

      return BackendResponse(success: true, payload: response.messageId);
    } catch (e) {
      return BackendResponse(success: false, payload: e);
    }
  }

@Vinzent03
Copy link
Collaborator Author

@haykodarb So your project is hosted on supabase and it already worked for you and stopped working now or is your project new and doesn't work?

@haykodarb
Copy link

haykodarb commented Jul 23, 2023

The project is a couple of months old, hosted on Supabase and I'm just now implementing the resend email functionality.

Testing the function threw the previously mentioned exception but now I'm getting the usual

AuthException(message: Email rate limit exceeded, statusCode: 429)

Which is fine. Not sure why it changed though, haven't changed anything on my side. Likely a reload/restart issue but I had already tried that.

@Vinzent03
Copy link
Collaborator Author

I guess your project is on the free plan? Please try to pause and unpause your project to hopefully apply the latest gotrue version.

@haykodarb
Copy link

Yes, I'll try that, thank you.

@haykodarb
Copy link

Paused and unpaused project, still getting this exception.

AuthException(message: Missing one of these types: signup, email_change, sms, phone_change, statusCode: 400)

After 3 times of getting that exception I get rate limited without receiving any emails.

AuthException(message: Email rate limit exceeded, statusCode: 429)

@dshukertjr
Copy link
Member

@haykodarb
I know it will give you an deprecation warning, but could you try calling resend method with type of OtpType.signup or OtpType.emailChange, whichever is appropriate in your case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants