Closed daskabe closed 1 month ago
Hello, @daskabe is your preferred username set up as required and as an alias? Per the Cognito docs here, it can be one but not both.
Hello @daskabe. This seems to be a Cognito bug. You are right, the creation of the userpool should fail when preferred_username
is selected as a required attribute.
You would need to create another userpool without the preferred_username
as a require attribute and then call the updateUserAttribute
API upon authentication and add a preferred_username
thats what i ended up doing to move forward with my development - created another userpool - But now my users cant sign in using their username. Currently just using email. I didn't bather setting preferred_username ; instead i saved the username to custom:username
attribute during signup to hopefully validate that somehow during sign up.
And how/why is account confirmation status related to a preferred_username? preferred_username is just attribute and does not need confirmation.
This is what i would want to see.
1) if user has all 3 selected in the following image, then preferred_username
should be settable field during sign up
2) dont call it User name
as its confusing; call it userHandle
because if you ask frontend engineer, username can be : email || phone || userHandle(eg elonMusk)
4) the signUp(...) function should just take object of attributes(some of which can be required based on user pool configuration), So no username
, password
and options.userAttributes
fields. Because right now i am confused what username:{email}
is actually accomplishing if my use case is: my users login using phone numbers.
But if i just send an object with all required and custom attributes; congito should just work based on how its configured during creation.
3) this section is redundant
If you select only phone number and email, your user will be prompted to select one of the two sign-in options when they sign up.
Cognito signIn(...) process should parse and validate the provided username - (one of email || phone || userHandle) and then perform login action...no need to force user to select the preferred way. Imagine having your email as preferred way but then you lose your email...how do you login and change your preference? Ideally i should be able to login with all my 3 options anytime (the userPool is configured to accept all 3)
@israx
@daskabe, closing this issue as it will be captured as a docs improvement in the above referenced amplify-docs
issue. You can track the progress there, but I'll leave another comment on here once the updates are merged in. Thanks!
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
Authentication
Amplify Version
v6
Amplify Categories
auth
Backend
CDK
Environment information
Describe the bug
preferred_username should not be a Required attribute IF it cant be set during user sign up flow.
Expected behavior
preferred_username should not be required field. if it is - it should be settable during signup.
the above code gives this error:
Reproduction steps
Create a userpool with preferred_username as required field and then try to create a user.
If this is system limitation then userpool creation should fail if preferred_username is set as required field.
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response