diff --git a/packages/core/__tests__/parseAmplifyOutputs.test.ts b/packages/core/__tests__/parseAmplifyOutputs.test.ts index 7d15f7b1f52..3dba9c821a8 100644 --- a/packages/core/__tests__/parseAmplifyOutputs.test.ts +++ b/packages/core/__tests__/parseAmplifyOutputs.test.ts @@ -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', () => { diff --git a/packages/core/src/parseAmplifyOutputs.ts b/packages/core/src/parseAmplifyOutputs.ts index ed742189266..2995f63f172 100644 --- a/packages/core/src/parseAmplifyOutputs.ts +++ b/packages/core/src/parseAmplifyOutputs.ts @@ -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, }; }