1

I am using aws-cognito UserPool (via. AWSMobileClient) for authentication of users to access the AWS Services. Currently the user may choose to log-in via Phone, Google and Facebook using Hosted UI option, which requires to initialise the AWSMobileClient, via. AWSMobileClient.default().initialize(<#T##completionHandler: (UserState?, Error?) -> Void##(UserState?, Error?) -> Void#>) Which returns me the current user state.

Use Case : I sign in to my application via UserPool, and the uninstall the application. When reinstalling the application I fetch the current user state, it returns as “Signed-In”.

How may I stop this behaviour?

1 Answers1

1

The "problem" is that AWS SDK stores the login information in the keychain, and this information is not deleted when the app is uninstalled.

Solution is to perform a signout in the first access of the user to the app. Use a Bool in UserDefaults to know if it is the first access.

Mohammad Sadiq
  • 5,070
  • 28
  • 29
  • Yes I am aware of this that the information is stored in Keychain, and when trying to login if the AWSMobileError is "invalidState" referring to user is already signed in, I then signout (to avoid redundant sign-out calls) and in completion I perform the signin action again. Also have called clearKeychain method to remove all logins from keychain when user signs out, but since using HostedUI here, the credentials from awsconfiguration.json is fetched and the last user state is fetched for the user while calling the initialise method of AWSMobileClient – Abhishek Singh Apr 10 '20 at 20:34