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

rm "username" from being parsed in amplify_outputs.json auth.username_attributes #13522

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

josefaidt
Copy link
Contributor

@josefaidt josefaidt commented Jun 19, 2024

Description of changes

modifies parseAmplifyOutputs to look for an empty array in auth.username_attributes instead of ["username"] to determine whether logging in with username is enabled

this is related to a similar change in the backend repo to remove username from the list of username_attributes in the outputs schema aws-amplify/amplify-backend#1636

valid username_attributes properties include email and phone_number https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.CfnUserPool.html#usernameattributes

these values come from the L1 CfnUserPool property, therefore will not include username but the absence of attributes that can be used in place of the username
https://github.com/aws-amplify/amplify-backend/blob/main/packages/auth-construct/src/construct.ts?rgh-link-date=2024-06-19T22%3A39%3A40Z#L952

Issue #, if available

Description of how you validated changes

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

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

@josefaidt josefaidt requested review from a team as code owners June 19, 2024 22:54
@@ -141,7 +141,7 @@ function parseAuth(
email: username_attributes.includes('email'),
phone: username_attributes.includes('phone_number'),
// Signing in with a username is not currently supported in Gen2, this should always evaluate to false
username: username_attributes.includes('username'),
username: username_attributes.length === 0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the backend is changing, then this fix makes sense. But I wonder if we should also support previous versions to avoid any breaking change.

Suggested change
username: username_attributes.length === 0,
username: username_attributes.length === 0 || username_attributes.includes('username') ,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was written with the outputs schema that had a reference to "username" for this value, however "username" would not be emitted from the construct. for this field, the absence of username attributes indicates "username"

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