Skip to content

Commit

Permalink
fix: don't remove session in resend (#717)
Browse files Browse the repository at this point in the history
## 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)
  • Loading branch information
Vinzent03 committed Jul 10, 2023
1 parent 44af61e commit 48f21e1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/GoTrueClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,11 @@ export default class GoTrueClient {
*/
async resend(credentials: ResendParams): Promise<AuthOtpResponse> {
try {
await this._removeSession()

if (credentials.type != "email_change" && credentials.type != "phone_change") {
await this._removeSession();
}

const endpoint = `${this.url}/resend`
if ('email' in credentials) {
const { email, type, options } = credentials
Expand Down

0 comments on commit 48f21e1

Please sign in to comment.