From e91815843e916dd5172ed1833050a2c86a66ecd1 Mon Sep 17 00:00:00 2001 From: dshukertjr <18113850+dshukertjr@users.noreply.github.com> Date: Mon, 24 Jul 2023 19:21:34 +0900 Subject: [PATCH 1/3] remove otp type deprecation --- packages/gotrue/lib/src/constants.dart | 2 -- packages/gotrue/lib/src/gotrue_client.dart | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/gotrue/lib/src/constants.dart b/packages/gotrue/lib/src/constants.dart index 90aff764..48401f4f 100644 --- a/packages/gotrue/lib/src/constants.dart +++ b/packages/gotrue/lib/src/constants.dart @@ -50,10 +50,8 @@ extension GenerateLinkTypeExtended on GenerateLinkType { enum OtpType { sms, phoneChange, - @Deprecated('Use OtpType.email instead') signup, invite, - @Deprecated('Use OtpType.email instead') magiclink, recovery, emailChange, diff --git a/packages/gotrue/lib/src/gotrue_client.dart b/packages/gotrue/lib/src/gotrue_client.dart index 92d7e18f..fb1e84a0 100644 --- a/packages/gotrue/lib/src/gotrue_client.dart +++ b/packages/gotrue/lib/src/gotrue_client.dart @@ -526,9 +526,13 @@ class GoTrueClient { ); } - ///Resends an existing signup confirmation email, email change email, SMS OTP or phone change OTP. + /// Resends an existing signup confirmation email, email change email, SMS OTP or phone change OTP. /// - ///Use [EmailResendParams] or [PhoneResendParams] to specify the type of resend. + /// Use [EmailResendParams] or [PhoneResendParams] to specify the type of resend. + /// + /// For [type] of [OtpType.signup] or [OtpType.emailChange] [email] must be + /// provided, and for [type] or [OtpType.sms] or [OtpType.phoneChange], + /// [phone] must be provided Future resend({ String? email, String? phone, @@ -538,6 +542,14 @@ class GoTrueClient { }) async { assert((email != null && phone == null) || (email == null && phone != null), '`email` or `phone` needs to be specified.'); + if (email != null) { + assert([OtpType.signup, OtpType.emailChange].contains(type), + 'email must be provided for type ${type.name}'); + } + if (phone != null) { + assert([OtpType.sms, OtpType.phoneChange].contains(type), + 'phone must be provided for type ${type.name}'); + } if (type != OtpType.emailChange && type != OtpType.phoneChange) { _removeSession(); From 36e4536463d8a8b8ef143673eff7146105ee3eb8 Mon Sep 17 00:00:00 2001 From: Tyler <18113850+dshukertjr@users.noreply.github.com> Date: Mon, 24 Jul 2023 22:05:25 +0900 Subject: [PATCH 2/3] Update packages/gotrue/lib/src/gotrue_client.dart Co-authored-by: Vinzent --- packages/gotrue/lib/src/gotrue_client.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/gotrue/lib/src/gotrue_client.dart b/packages/gotrue/lib/src/gotrue_client.dart index fb1e84a0..fef0cf4e 100644 --- a/packages/gotrue/lib/src/gotrue_client.dart +++ b/packages/gotrue/lib/src/gotrue_client.dart @@ -528,7 +528,6 @@ class GoTrueClient { /// Resends an existing signup confirmation email, email change email, SMS OTP or phone change OTP. /// - /// Use [EmailResendParams] or [PhoneResendParams] to specify the type of resend. /// /// For [type] of [OtpType.signup] or [OtpType.emailChange] [email] must be /// provided, and for [type] or [OtpType.sms] or [OtpType.phoneChange], From b16378ff1699a8154fc5e6ac5f73ec860328a573 Mon Sep 17 00:00:00 2001 From: Tyler <18113850+dshukertjr@users.noreply.github.com> Date: Mon, 24 Jul 2023 22:05:46 +0900 Subject: [PATCH 3/3] Update packages/gotrue/lib/src/gotrue_client.dart --- packages/gotrue/lib/src/gotrue_client.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/gotrue/lib/src/gotrue_client.dart b/packages/gotrue/lib/src/gotrue_client.dart index fef0cf4e..8da14486 100644 --- a/packages/gotrue/lib/src/gotrue_client.dart +++ b/packages/gotrue/lib/src/gotrue_client.dart @@ -528,7 +528,6 @@ class GoTrueClient { /// Resends an existing signup confirmation email, email change email, SMS OTP or phone change OTP. /// - /// /// For [type] of [OtpType.signup] or [OtpType.emailChange] [email] must be /// provided, and for [type] or [OtpType.sms] or [OtpType.phoneChange], /// [phone] must be provided