Skip to content
This repository has been archived by the owner on May 13, 2023. It is now read-only.

fix: signedIn event will not fire for passwordRecovery event #136

Merged
merged 2 commits into from
Apr 7, 2023
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion lib/src/gotrue_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,10 @@ class GoTrueClient {

if (storeSession == true) {
_saveSession(session);
_notifyAllSubscribers(AuthChangeEvent.signedIn);
if (redirectType == 'recovery') {
_notifyAllSubscribers(AuthChangeEvent.passwordRecovery);
} else {
_notifyAllSubscribers(AuthChangeEvent.signedIn);
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/client_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ void main() {
);
});

test('Session recovery succedes after retries', () async {
test('Session recovery succeeds after retries', () async {
await client.recoverSession(
'{"currentSession":{"access_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2ODAzNDE3MDUsInN1YiI6IjRkMjU4M2RhLThkZTQtNDlkMy05Y2QxLTM3YTlhNzRmNTViZCIsImVtYWlsIjoiZmFrZTE2ODAzMzgxMDVAZW1haWwuY29tIiwicGhvbmUiOiIiLCJhcHBfbWV0YWRhdGEiOnsicHJvdmlkZXIiOiJlbWFpbCIsInByb3ZpZGVycyI6WyJlbWFpbCJdfSwidXNlcl9tZXRhZGF0YSI6eyJIZWxsbyI6IldvcmxkIn0sInJvbGUiOiIiLCJhYWwiOiJhYWwxIiwiYW1yIjpbeyJtZXRob2QiOiJwYXNzd29yZCIsInRpbWVzdGFtcCI6MTY4MDMzODEwNX1dLCJzZXNzaW9uX2lkIjoiYzhiOTg2Y2UtZWJkZC00ZGUxLWI4MjAtZjIyOWYyNjg1OGIwIn0.0x1rFlPKbIU1rZPY1SH_FNSZaXerfkFA1Y-EOlhuzUs","expires_in":3600,"refresh_token":"-yeS4omysFs9tpUYBws9Rg","token_type":"bearer","provider_token":null,"provider_refresh_token":null,"user":{"id":"4d2583da-8de4-49d3-9cd1-37a9a74f55bd","app_metadata":{"provider":"email","providers":["email"]},"user_metadata":{"Hello":"World"},"aud":"","email":"fake1680338105@email.com","phone":"","created_at":"2023-04-01T08:35:05.208586Z","confirmed_at":null,"email_confirmed_at":"2023-04-01T08:35:05.220096086Z","phone_confirmed_at":null,"last_sign_in_at":"2023-04-01T08:35:05.222755878Z","role":"","updated_at":"2023-04-01T08:35:05.226938Z"}},"expiresAt":1680341705}');
expect(httpClient.retryCount, 3);
Expand Down
13 changes: 11 additions & 2 deletions test/custom_http_client.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import 'dart:convert';

import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';
import 'package:http/http.dart';
import 'package:universal_io/io.dart';

import 'utils.dart';

class CustomHttpClient extends BaseClient {
@override
Future<StreamedResponse> send(BaseRequest request) async {
Expand Down Expand Up @@ -73,13 +76,19 @@ class RetryTestHttpClient extends BaseClient {
retryCount++;
throw SocketException('Retry #${retryCount + 1}');
}
final jwt = JWT(
{'exp': (DateTime.now().millisecondsSinceEpoch / 1000).round() + 60},
subject: userId1,
);

return StreamedResponse(
Stream.value(
utf8.encode(
jsonEncode(
{
'access_token':
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2ODAzNDU1MzksInN1YiI6IjE4YmM3YTRlLWMwOTUtNDU3My05M2RjLWUwYmUyOWJhZGE5NyIsImVtYWlsIjoiZmFrZTFAZW1haWwuY29tIiwicGhvbmUiOiIxNjY2MDAwMDAwMDAiLCJhcHBfbWV0YWRhdGEiOnsicHJvdmlkZXIiOiJlbWFpbCIsInByb3ZpZGVycyI6WyJlbWFpbCJdfSwidXNlcl9tZXRhZGF0YSI6e30sInJvbGUiOiIiLCJhYWwiOiJhYWwxIiwiYW1yIjpbeyJtZXRob2QiOiJwYXNzd29yZCIsInRpbWVzdGFtcCI6MTY4MDM0MTkzOX1dLCJzZXNzaW9uX2lkIjoiYTg3NjdiOGEtMDcxMS00MGMyLTkzYTEtYTA4MTI3YzFjMzUzIn0.xNV0fCVB8QeeDp44UXlsQ-SdDZm8ZFPKuZVGVZE24Tw',
'access_token': jwt.sign(
SecretKey('37c304f8-51aa-419a-a1af-06154e63707a'),
),
'token_type': 'bearer',
'expires_in': 3600,
'refresh_token': 'tDoDnvj5MKLuZOQ65KyVfQ',
Expand Down