pocketbase / dart-sdk

PocketBase Dart SDK
https://pub.dev/packages/pocketbase
MIT License
511 stars 51 forks source link

Bug: authStore did not save token and model. #35

Closed usamashafiqs closed 1 year ago

usamashafiqs commented 1 year ago

authStore did not save token, model on device persistent storage.

final auth = await pb.collection('users').authWithPassword('test_username', '12345678');
print(pb.authStore.token);
print(pb.authStore.isValid);
print(pb.authStore.model);

Result

I/flutter (18317):
I/flutter (18317): false
I/flutter (18317): null

I try to manually save the token and model result are same.

final auth = await pb.collection('users').authWithPassword('test_username', '12345678');
pb.authStore.save(auth.token, auth.record);
print(pb.authStore.token);
print(pb.authStore.isValid);
print(pb.authStore.model);

Result

I/flutter (18317):
I/flutter (18317): false
I/flutter (18317): null
ganigeorgiev commented 1 year ago

I'm not able to reproduce it with Dart SDK v0.9.1.

Future<void> authTest() async {
  final pb = PocketBase("http://127.0.0.1:8090");

  await pb
      .collection('users')
      .authWithPassword('test@example.com', '1234567890');

  print(pb.authStore.token);
  print(pb.authStore.isValid);
  print(pb.authStore.model);
}

Make sure that the Future doesn't throw an error (check Error handling).

Also keep in mind that the SDK store is currently not persistent (you can check https://github.com/pocketbase/dart-sdk/issues/13, pocketbase#1887).

If that's not the case, please provide a minimal reproducible repo and I'll try to investigate it.