Closed PfernFSU closed 2 years ago
Hi @PfernFSU, thanks for trying out the dev-preview! I was able to isolate the cause of issue 1 and will have a fix out soon. I'll have a look at issue 2 afterwards. Cheers!
Hi @PfernFSU, I haven't been able to reproduce issue 2 yet. Are you using MultiAuth in DataStore? Could you run the app in Xcode and see if any error logs are bring produced in native code?
Could you also share the code you're using to sign out and clear DataStore?
Hi @dnys1 - thank you again for your help. I did run it in XCode and saw something that may be an error. It is:
2022-08-06 17:43:25.126970-0400 Runner[80006:25079432] [db] _LSSchemaConfigureForStore failed with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
I see the below error as well but believe it is expected because the user is signed out?
flutter: ⛔️ SEVERE: Emitted error
2022-08-06 17:43:25.639044-0400 Runner[80006:25080546] flutter: ERROR | _NativeAmplifyAuthCognito | Error fetching session for native plugin: NotAuthorizedException [Unauthenticated access is not supported for this identity pool., null, null]
2022-08-06 17:43:25.639310-0400 Runner[80006:25080546]
As far as the code to sign out, we do this:
Future<void> signOut() {
return authExceptionHandler(() async {
await Amplify.Auth.signOut(
options: const SignOutOptions(
globalSignOut: true,
),
);
await Amplify.DataStore.clear();
}());
}
As far as using MultiAuth in the DataStore, I do not believe we are. I put my aws config in the original report if that helps? Here is how we configure everything:
Future<void> _configureAmplify() async {
try {
await Amplify.addPlugins([
AmplifyAPI(),
AmplifyAuthCognito(),
AmplifyDataStore(modelProvider: ModelProvider.instance),
]);
await Amplify.configure(amplifyConfigStr);
} on AmplifyAlreadyConfiguredException catch (e) {
debugPrint('App already configured. Error: $e');
}
setState(() => _isAmplifyConfigured = true);
FlutterNativeSplash.remove(); // clear splash
}
}
Thanks again.
Hi @PfernFSU - my pleasure and thank you as well for your very detailed report and follow up. It's a huge help when going to look at these issues!
We've released a fix for issue 1 in the latest auth package!
I'm still working on reproducing issue 2. The error messages you posted look correct to me, since after calling DataStore.clear
, DataStore will try to sync with the cloud. To do so, it needs credentials, but since you've just signed out, there are no credentials which is why the error is being thrown. This indicates to me also that credentials are being successfully cleared, since otherwise, we would not see that error message. It also means that DataStore.clear
is successfully finishing, otherwise we would not see it try to access credentials. This makes it very difficult to guess why you could be seeing both credentials and DataStore not being cleared as expected.
Hi @dnys1 - so we have done a ton of investigation on our side and I owe you a huge apology. Our riverpod state management was not correct and it was holding onto some of the old values. After we fix this, we no longer see the issue that was reported in #2. Once again, I am incredibly sorry to waste your time. And thank you again for fixing the first issue and being so responsive.
Honestly, it's been great working with you too, and I encourage you to always reach out if you face any issue whatsoever. It's great to know the ins and outs of how our customers use Amplify in real life and I always seem to learn something along the way :-) cheers!
Description
We read the blog post announcing the developer preview, so we decided to upgrade as we were experiencing some of the race conditions you guys mentioned as fixed. However, we experienced two distinct issues. I am not sure where to write them, so I thought it best to condense it into a single bug/issue report. I briefly scanned the open issues and did not see any. We are only using mobile and not targeting web.
Relevant pubspec.yaml:
Issue 1
We have MFA set up in Cognito and any log in from a new device should trigger an SMS verification with the 6-digit code being sent. This is working well, and the code works. However, the code is always sent now upon login. Before, the device used to be remembered. I can log out and then log back in and each time I will have to follow the flow to enter the 6-digit passcode that was sent via SMS. I was not expecting to be required to enter the SMS code each time, and before the developer preview branch I was never required to do so.
Issue 2
If I log in as person A, then sign out, then log in as person B, I will have person A's datastore on my computer and inspecting their user I can see their email/username from Cognito. We have custom fields in Cognito (like a user's company) so the old user is still held somewhere. It is like the whole session is stored on the device and never cleansed, which results in the datastore being refetched for the wrong user. We call clear() on the datastore while signing out via:
Amplify.DataStore.clear();
so it leads me to believe the AWS token is stored when it should not be and therefor fetching the wrong datastore. Logging in with person C after person A and B will still display person A's AWS info taken from Cognito (we display their email/phone number on a profile screen). To recap, this below line returns the first person to ever log in on the device, no matter who is logged in:Amplify.Auth.getCurrentUser();
These two issues only appear on the developer preview branch, and are not on the latest stable branch.
Amplify config (with sensitive info asterisk'ed out):
Please let me know if I can help further. And thank you for all you do!
Categories
Steps to Reproduce
Issue 1:
Issue 2:
final userAttributes = await Amplify.Auth.fetchUserAttributes();
Screenshots
No response
Platforms
Android Device/Emulator API Level
No response
Environment
Dependencies
Device
iphone11 (physical device) and also iPhone 13 Pro Emulator running on a iMac
OS
15.5 (actual device)
CLI Version
N/A
Additional Context
No response