Skip to content

Commit

Permalink
fix(gotrue): Signing in does not remove the session unless the operat…
Browse files Browse the repository at this point in the history
…ion 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
  • Loading branch information
dshukertjr authored Jun 11, 2024
1 parent 98718b1 commit b2854c5
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions packages/gotrue/lib/src/gotrue_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ class GoTrueClient {
Map<String, dynamic>? data,
String? captchaToken,
}) async {
_removeSession();

final response = await _fetch.request(
'$_url/signup',
RequestMethodType.post,
Expand Down Expand Up @@ -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<String, dynamic> response;

if (email != null) {
Expand Down Expand Up @@ -261,8 +257,6 @@ class GoTrueClient {
required String password,
String? captchaToken,
}) async {
_removeSession();

late final Map<String, dynamic> response;

if (email != null) {
Expand Down Expand Up @@ -315,7 +309,6 @@ class GoTrueClient {
String? scopes,
Map<String, String>? queryParams,
}) async {
_removeSession();
return _getUrlForProvider(
provider,
url: '$_url/authorize',
Expand Down Expand Up @@ -393,8 +386,6 @@ class GoTrueClient {
String? nonce,
String? captchaToken,
}) async {
_removeSession();

if (provider != OAuthProvider.google &&
provider != OAuthProvider.apple &&
provider != OAuthProvider.kakao) {
Expand Down Expand Up @@ -458,8 +449,6 @@ class GoTrueClient {
String? captchaToken,
OtpChannel channel = OtpChannel.sms,
}) async {
_removeSession();

if (email != null) {
String? codeChallenge;
if (_flowType == AuthFlowType.pkce) {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -584,7 +569,6 @@ class GoTrueClient {
'providerId or domain has to be provided.',
);

_removeSession();
String? codeChallenge;
String? codeChallengeMethod;
if (_flowType == AuthFlowType.pkce) {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b2854c5

Please sign in to comment.