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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/core/__tests__/parseAmplifyOutputs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,14 @@ describe('parseAmplifyOutputs tests', () => {
expect(result.Auth?.Cognito.loginWith?.email).toBe(true);
expect(result.Auth?.Cognito.loginWith?.phone).toBe(true);
expect(result.Auth?.Cognito.loginWith?.username).toBe(false);

// Username
testAmplifyOutputs.auth.username_attributes = [];
result = parseAmplifyOutputs(testAmplifyOutputs);

expect(result.Auth?.Cognito.loginWith?.email).toBe(false);
expect(result.Auth?.Cognito.loginWith?.phone).toBe(false);
expect(result.Auth?.Cognito.loginWith?.username).toBe(true);
});

describe('storage tests', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/parseAmplifyOutputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"

};
}

Expand Down
Loading