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

feat(auth): add userID property to AuthSignUpResult #3192

Merged
merged 6 commits into from
Aug 30, 2023
Merged

Conversation

atierian
Copy link
Member

@atierian atierian commented Aug 30, 2023

The original PR #3179 was reverted so that another change could be released first.

See #3191 for reference.


Description

Adds a userID property to AuthSignUpResult.

Currently, this property is accessible when the AuthSignUpResult().nextStep is AuthSignUpStep.confirmUser through the case's associated values.

The typical flow is signUp() --> .confirmUser --> confirmSignUp() --> .done.

confirmSignUp (ConfirmSignUp) doesn't return a userID (UserSub). However, signUp() --> .done is also a valid flow with the use of a custom verification flow. In this case, we receive the userID but we're preventing the caller from accessing it. This change provides the userID in the AuthSignUpResult if it's returned by the service, regardless of the nextStep.

Platform Parity

This change brings Amplify Swift in parity with Android, Flutter, and JS.

NOTE:
This change can be confusing because AuthSignUpResult and AuthSignUpStep.confirmUser both contain the same userID value.

let result = try await Amplify.Auth.signUp(...)

result.userID // "abc123"
switch result {
case .confirmUser(_, _, let userID):
  userID // "abc123"
...
}

The associated value on .confirmUser is no longer necessary, but removing would be a breaking change. Something to consider for vNext.

Misc. Changes

Moved from wait(for:) to await fulfillment(of:) for two test cases that were being problematic.

General Checklist

  • Added new tests to cover change, if needed
  • Build succeeds with all target using Swift Package Manager
  • All unit tests pass
  • All integration tests pass
  • Security oriented best practices and standards are followed (e.g. using input sanitization, principle of least privilege, etc)
  • Documentation update for the change if required
  • PR title conforms to conventional commit style
  • New or updated tests include Given When Then inline code documentation and are named accordingly testThing_condition_expectation()
  • If breaking change, documentation/changelog update with migration instructions

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@atierian atierian requested a review from a team as a code owner August 30, 2023 15:52
@atierian atierian changed the title Usersub on signup feat(auth): add userID property to AuthSignUpResult Aug 30, 2023
@atierian atierian merged commit ac1a266 into main Aug 30, 2023
149 checks passed
@atierian atierian deleted the usersub-on-signup branch August 30, 2023 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants