Search code examples
aws-amplify

Amplify React Federated sign in asks for verify email every sign in


Both the google and facebook federated sign in methods asks users to verify their emails on every sign in, regardless of whether users have already verfied their email. How do I make this stop after first verification?

this is the component in quesiton

    <AmplifyAuthenticator usernameAlias="email">
    <AmplifySignIn headerText="Sign into MyFive Account" slot="sign-in">
      <AmplifyFacebookButton
        slot="federated-buttons"
        onClick={() =>
          Auth.federatedSignIn({
            provider: "Facebook",
          })
        }
      />
      <AmplifyGoogleButton
        slot="federated-buttons"
        onClick={() => Auth.federatedSignIn({ provider: "Google" })}
      />
    </AmplifySignIn>
  </AmplifyAuthenticator>

this is the message enter image description here


Solution

  • Here is the solution proposed by the AWS Cognito docs:

    You can't verify a mapped email address using a one-time code. Instead, map an attribute from your identity provider to get the verification status. For example, Google and most OIDC providers include the email_verified attribute.

    As mentioned above, Google provides the attribute, which you can use to detect if the email has been verified.

    Unfortunately, this is not the case for Facebook authentication. One of the solutions is to implement Post Authentication lambda trigger as described here.