From ea768d5f911150c97f369da76512435eab8dae21 Mon Sep 17 00:00:00 2001 From: mtte Date: Fri, 30 Jun 2023 19:33:57 +0200 Subject: [PATCH 1/2] fix: option for redirect URL when resending confirmation email (#718) --- src/GoTrueClient.ts | 1 + src/lib/types.ts | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/GoTrueClient.ts b/src/GoTrueClient.ts index 54f32902..a97bc829 100644 --- a/src/GoTrueClient.ts +++ b/src/GoTrueClient.ts @@ -729,6 +729,7 @@ export default class GoTrueClient { const { email, type, options } = credentials const { error } = await _request(this.fetch, 'POST', endpoint, { headers: this.headers, + redirectTo: options?.redirectTo, body: { email, type, diff --git a/src/lib/types.ts b/src/lib/types.ts index a82e74da..64e4fd0a 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -551,6 +551,8 @@ export type ResendParams = type: Extract email: string options?: { + /** The redirect url embedded in the email link */ + redirectTo?: string /** Verification token received when the user completes the captcha on the site. */ captchaToken?: string } From b1a36efadf2419746c4cd8a1831c4da6577e241e Mon Sep 17 00:00:00 2001 From: mtte Date: Fri, 30 Jun 2023 19:37:03 +0200 Subject: [PATCH 2/2] fix: rename parameter (#718) --- src/GoTrueClient.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/GoTrueClient.ts b/src/GoTrueClient.ts index a97bc829..d832558a 100644 --- a/src/GoTrueClient.ts +++ b/src/GoTrueClient.ts @@ -721,12 +721,12 @@ export default class GoTrueClient { /** * Resends an existing signup confirmation email, email change email, SMS OTP or phone change OTP. */ - async resend(credentials: ResendParams): Promise { + async resend(params: ResendParams): Promise { try { await this._removeSession() const endpoint = `${this.url}/resend` - if ('email' in credentials) { - const { email, type, options } = credentials + if ('email' in params) { + const { email, type, options } = params const { error } = await _request(this.fetch, 'POST', endpoint, { headers: this.headers, redirectTo: options?.redirectTo, @@ -737,8 +737,8 @@ export default class GoTrueClient { }, }) return { data: { user: null, session: null }, error } - } else if ('phone' in credentials) { - const { phone, type, options } = credentials + } else if ('phone' in params) { + const { phone, type, options } = params const { data, error } = await _request(this.fetch, 'POST', endpoint, { headers: this.headers, body: {