How to use the @aws-amplify/auth.forgotPassword function in @aws-amplify/auth

To help you get started, we’ve selected a few @aws-amplify/auth examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yhenni1989 / ReactNativeAuth / src / components / screens / ForgetPasswordScreen.js View on Github external
async forgotPassword() {
    const { username } = this.state
    await Auth.forgotPassword(username)
    .then(data => console.log('New code sent', data))
    .catch(err => {
      if (! err.message) {
        console.log('Error while setting up the new password: ', err)
        Alert.alert('Error while setting up the new password: ', err)
      } else {
        console.log('Error while setting up the new password: ', err.message)
        Alert.alert('Error while setting up the new password: ', err.message)
      }
    })
  }
  // Upon confirmation redirect the user to the Sign In page
github aws-amplify / amplify-js / packages / aws-amplify-react / src / Auth / ForgotPassword.tsx View on Github external
send() {
		const { authData = {} } = this.props;
		const username = this.getUsernameFromInput() || authData.username;
		if (!Auth || typeof Auth.forgotPassword !== 'function') {
			throw new Error(
				'No Auth module found, please ensure @aws-amplify/auth is imported'
			);
		}
		Auth.forgotPassword(username)
			.then(data => {
				logger.debug(data);
				this.setState({ delivery: data.CodeDeliveryDetails });
			})
			.catch(err => this.error(err));
	}
github webiny / webiny-js / packages / app-plugin-security-cognito / src / components / cognito / states / ForgotPassword.js View on Github external
requestCode = async data => {
        this.setState({ loading: true });
        const { username } = data;
        try {
            const res = await Auth.forgotPassword(username.toLowerCase());
            debug("Forgot password %O", res);
            this.setState({ loading: false, codeSent: res.CodeDeliveryDetails, error: null });
        } catch (err) {
            if (err.code === "LimitExceededException") {
                this.setState({
                    loading: false,
                    error: `You can't change password that often. Please try later.`
                });
                return;
            }

            this.setState({ loading: false, error: err.message });
        }
    };
github TreeHacks / root / src / store / auth / actions.ts View on Github external
return dispatch => {
    dispatch(loadingStart());
    Auth.forgotPassword(data.email.toLowerCase())
      .then(() => dispatch(setAuthPage("forgotPasswordSubmit", "Verification email sent. Please check your email for a code and enter the code below to change your password. If you don't see the email, please check your spam folder.")))
      .catch(e => dispatch(onAuthError(e.message)))
      .then(() => dispatch(loadingEnd()))
  }
}