aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.43k stars 2.13k forks source link

Cognito Forgot Password API Doesn't Return Error When Email Not Sent #7696

Closed ChihweiLHBird closed 3 years ago

ChihweiLHBird commented 3 years ago
Auth.forgotPassword(user_email).then(res => {
                    this.setState({...});
                }).catch(err => {
                    console.log(err);
                })

This piece of code does not catch any error when the confirmed user account's email is not verified in Cognito, for example, accounts by federated login. And the user cannot get the password reset code as well. Can Amplify raise an error in this situation? Or is there any way to check whether or not the users' email address was verified (and resend the verification link or code) without signing in?

sammartinez commented 3 years ago

Can you provide your package.json along with your environment settings?

Please use the follow command:

npx envinfo --system --binaries --browsers --npmPackages --npmGlobalPackages

Thanks ahead of time!

ChihweiLHBird commented 3 years ago

@sammartinez No problem.

  System:
    OS: Windows 10 10.0.19042
    CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
    Memory: 11.61 GB / 31.93 GB
  Binaries:
    Node: 14.15.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 7.2.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.423.0), Chromium (88.0.705.63)
    Internet Explorer: 11.0.19041.1
  npmPackages:
    @material-ui/core: ^4.11.3 => 4.11.3
    @material-ui/icons: ^4.11.2 => 4.11.2
    @material-ui/lab: ^4.0.0-alpha.56 => 4.0.0-alpha.57
    @mui-treasury/styles: ^1.13.1 => 1.13.1
    @testing-library/jest-dom: ^5.11.9 => 5.11.9
    @testing-library/react: ^11.2.5 => 11.2.5
    apexcharts: ^3.24.0 => 3.24.0
    aws-amplify: ^3.3.17 => 3.3.17
    aws-sdk: ^2.839.0 => 2.839.0
    axios: ^0.21.1 => 0.21.1
    babel-cli: ^6.26.0 => 6.26.0
    babel-preset-env: ^1.7.0 => 1.7.0
    babel-preset-react: ^6.24.1 => 6.24.1
    babel-register: ^6.26.0 => 6.26.0
    baseui: ^9.109.0 => 9.109.0
    eslint: ^7.19.0 => 7.19.0
    eslint-plugin-react: ^7.22.0 => 7.22.0
    ncp: ^2.0.0 => 2.0.0
    node-sass: ^4.14.1 => 4.14.1
    nuka-carousel: ^4.7.5 => 4.7.5
    prop-types: ^15.7.2 => 15.7.2
    query-string: ^6.13.8 => 6.13.8
    react: ^16.14.0 => 16.14.0
    react-animated-slider: ^2.0.0 => 2.0.0
    react-apexcharts: ^1.3.7 => 1.3.7
    react-copy-to-clipboard: ^5.0.3 => 5.0.3
    react-device-detect: ^1.15.0 => 1.15.0
    react-dom: ^16.14.0 => 16.14.0
    react-elastic-carousel: ^0.10.0 => 0.10.0
    react-helmet: ^6.1.0 => 6.1.0
    react-image-gallery: ^1.0.8 => 1.0.8
    react-multi-carousel: ^2.6.1 => 2.6.1
    react-native: ^0.63.3 => 0.63.4
    react-number-format: ^4.4.4 => 4.4.4
    react-player: ^2.8.2 => 2.8.2
    react-redux: ^7.2.2 => 7.2.2
    react-refresh: ^0.9.0 => 0.9.0
    react-router: ^5.2.0 => 5.2.0
    react-router-dom: ^5.2.0 => 5.2.0
    react-router-last-location: ^2.0.1 => 2.0.1
    react-router-sitemap: ^1.2.0 => 1.2.0
    react-scripts: ^4.0.1 => 4.0.1
    react-slick: ^0.27.14 => 0.27.14
    react-star-ratings: ^2.3.0 => 2.3.0
    redux: ^4.0.5 => 4.0.5
    redux-thunk: ^2.3.0 => 2.3.0
    rsuite: ^4.8.9 => 4.8.9
    slick-carousel: ^1.8.1 => 1.8.1
    styled-components: ^5.2.1 => 5.2.1
    styletron-react: ^5.2.7 => 5.2.7
  npmGlobalPackages:
    npm-check: 5.9.2
    npm: 7.2.0
    yarn: 1.22.10
sammartinez commented 3 years ago

Apologizes on the delay here @ChihweiLHBird. Have you gone through our documentation around this? There are other APIs that correlate to customer verification tied to what seems that you are looking for. Please let us know if you have any further questions and if you do, please share more of a code snippet of what you are trying to accomplish. Thanks!

chrisbonifacio commented 3 years ago

@ChihweiLHBird Closing this for now as we have not heard back from you in over a week. Please re-open with some additional information if you still need assistance. Thank you!

Baloc22m commented 2 years ago

I am seeing the same issue. When I execute the below code with invalid username, it still has a valid response: CodeDeliveryDetails, it is sending a verification code to some random email or number. I am confused why is this happening.

await Auth.forgotPassword(username).then(response => { if (response) { navigation!.navigate('NewPasswordPage', {username: username}); } else { setError('username', { type: 'manual', message: 'User does not exist', }); } });

I entered invalid username and the response is: CodeDeliveryDetails: AttributeName: "email" DeliveryMedium: "EMAIL" Destination: "B@y.com"

Can someone will tell me if this is a known bug and if there is a workaround

ChihweiLHBird commented 2 years ago

Apologizes on the delay here @ChihweiLHBird. Have you gone through our documentation around this? There are other APIs that correlate to customer verification tied to what seems that you are looking for. Please let us know if you have any further questions and if you do, please share more of a code snippet of what you are trying to accomplish. Thanks!

Thank you for the response and sorry about forgetting about this issue and didn't reply earlier.

I no longer use Amplify since I no longer work on that project. But I still don't understand which API in the docs can be used for this issue.

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.