Skip to content

fix(gotrue): Signing in does not remove the session unless the operation succeeds. #945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading