はじめに
AmplifyとReactを使用して爆速でユーザー認証画面を実装するの内容に沿ってユーザー認証を実装すると、メールアドレスの他にユーザー名が必須となり、ログイン時にもユーザー名の入力が必要になる。そこで、メールアドレスでログインできるようにしたい。
参考: https://github.com/aws-amplify/amplify-js/issues/1634
手順
設定ファイルの作成
amplify add auth
pushする前に、amplify/backend/auth/{your-project}/{your-project}-cloudformation-template.ymlにUsernameAttributesを追記する。
Type: AWS::Cognito::UserPool
Properties:
UsernameAttributes:
- "email"
UserPoolName: !Ref userPoolName
amplify push
push後は変更が効かないので注意が必要。