From b2854c564f0f5e7844302a2f7e63394fa4c6fc34 Mon Sep 17 00:00:00 2001 From: Tyler Date: Tue, 11 Jun 2024 14:25:54 +0900 Subject: [PATCH] fix(gotrue): Signing in does not remove the session unless the operation succeeds. (#945) * fix: signing in does not remove the session unless the operation succedes. * set local session and user to null within signout * add remove session to call refresh token --- packages/gotrue/lib/src/gotrue_client.dart | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/packages/gotrue/lib/src/gotrue_client.dart b/packages/gotrue/lib/src/gotrue_client.dart index 7de0f619..20501ff5 100644 --- a/packages/gotrue/lib/src/gotrue_client.dart +++ b/packages/gotrue/lib/src/gotrue_client.dart @@ -140,8 +140,6 @@ class GoTrueClient { Map? data, String? captchaToken, }) async { - _removeSession(); - final response = await _fetch.request( '$_url/signup', RequestMethodType.post, @@ -194,8 +192,6 @@ class GoTrueClient { assert((email != null && phone == null) || (email == null && phone != null), 'You must provide either an email or phone number'); - _removeSession(); - late final Map response; if (email != null) { @@ -261,8 +257,6 @@ class GoTrueClient { required String password, String? captchaToken, }) async { - _removeSession(); - late final Map response; if (email != null) { @@ -315,7 +309,6 @@ class GoTrueClient { String? scopes, Map? queryParams, }) async { - _removeSession(); return _getUrlForProvider( provider, url: '$_url/authorize', @@ -393,8 +386,6 @@ class GoTrueClient { String? nonce, String? captchaToken, }) async { - _removeSession(); - if (provider != OAuthProvider.google && provider != OAuthProvider.apple && provider != OAuthProvider.kakao) { @@ -458,8 +449,6 @@ class GoTrueClient { String? captchaToken, OtpChannel channel = OtpChannel.sms, }) async { - _removeSession(); - if (email != null) { String? codeChallenge; if (_flowType == AuthFlowType.pkce) { @@ -530,10 +519,6 @@ class GoTrueClient { assert((email != null && phone == null) || (email == null && phone != null), '`email` or `phone` needs to be specified.'); - if (type != OtpType.emailChange && type != OtpType.phoneChange) { - _removeSession(); - } - final body = { if (email != null) 'email': email, if (phone != null) 'phone': phone, @@ -584,7 +569,6 @@ class GoTrueClient { 'providerId or domain has to be provided.', ); - _removeSession(); String? codeChallenge; String? codeChallengeMethod; if (_flowType == AuthFlowType.pkce) { @@ -676,10 +660,6 @@ class GoTrueClient { 'phone must be provided for type ${type.name}'); } - if (type != OtpType.emailChange && type != OtpType.phoneChange) { - _removeSession(); - } - final body = { if (email != null) 'email': email, if (phone != null) 'phone': phone,