Skip to content
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

Custom auth callback not reset on signOut #2261

Closed
MightyFine opened this issue Jan 28, 2020 · 5 comments
Closed

Custom auth callback not reset on signOut #2261

MightyFine opened this issue Jan 28, 2020 · 5 comments
Assignees
Labels
bug Something isn't working mobile client Issues related to AWSMobileClient work in progress Issues was triaged and investigation done

Comments

@MightyFine
Copy link

The tl;dr is that when I call AWSMobileClient.default().signOut() there's a custom auth challenge task (UserPoolOperationsHandler.sharedInstance.customAuthChallengeTaskCompletionSource which is an internal API) that isn't reset, so when I subsequently call AWSMobileClient.default().signIn(...) it tries to sign in via a custom auth challenge and then I get an error "Missing required parameter ANSWER".

The reason I'm getting into this state is that I'm working on a feature where the flow is that a user can enter a phone number to sign in, which is implemented on AWS as a custom auth challenge which sends a code, which the user then inputs to confirm, and they're signed in.

Part of the requirement is that the user can tap on a "I didn't receive a code" button, which takes them back, and they can change their phone number or just sign in again to retrigger the flow.

The problem I'm running into is that once AWSMobileClient signs in and is issued a custom auth challenge, it sets a customAuthChallengeTaskCompletionSource task, which is then what's used during confirmSignIn to perform the confirmation. I can see that this is also used in signIn if it is populated, and after it's used is the only time that it's set back to nil.

The problem that this poses is that if AWSMobileClient.default().signOut() is called, there's a flow internally which checks for populated callbacks and eventually calls invalidateSignInCallbacks, which sets the sign in callbacks to nil, but the auth tasks aren't included in this and don't have any apparent way to be reset.

It seems to me like signOut() would also be the place to reset the customAuthChallengeTaskCompletionSource value and the other auth tasks, since if signOut() is invoked, it doesn't seem to make sense for the API to still be in a state where it's going to try and fill a custom auth challenge when a user signs in again?

There's a good chance I'm misunderstanding the SDK and how it works internally, so if anyone cares to correct me, please do, and if anyone has a workaround or a way this is meant to be used, I'd appreciate it!

It's worth noting that aside from this one edge case, the rest of the custom auth works properly, so our implementation is doing what it's meant to do aside from this.

Thanks,
Tim

@kneekey23 kneekey23 added mobile client Issues related to AWSMobileClient bug Something isn't working investigating This issue is being investigated labels Jan 28, 2020
@kneekey23
Copy link
Contributor

hi @MightyFine I reproduced this bug pretty quickly and just submitted a PR for it as you can see above. This seems to correct this issue, I will get this merged in as soon as a CR takes place. Thanks!

@MightyFine
Copy link
Author

Hey @kneekey23, that's awesome, thank you!

@kneekey23 kneekey23 added work in progress Issues was triaged and investigation done and removed investigating This issue is being investigated labels Jan 30, 2020
@kneekey23
Copy link
Contributor

Closing issue as PR has been merged in

@kneekey23 kneekey23 self-assigned this Jan 31, 2020
@Ricardo1980
Copy link

@MightyFine
I'm implementing the same flow.
To resend the code again, do you call AWSMobileClient.default().signOut() before calling signUp/signIn again?
Thanks.

@MightyFine
Copy link
Author

@MightyFine
I'm implementing the same flow.
To resend the code again, do you call AWSMobileClient.default().signOut() before calling signUp/signIn again?
Thanks.

Sorry @Ricardo1980, I've moved onto another role so I don't have access to that project and couldn't tell you exactly 😅 good luck though!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mobile client Issues related to AWSMobileClient work in progress Issues was triaged and investigation done
Projects
None yet
Development

No branches or pull requests

3 participants