How to use the aws-amplify.Auth.signIn function in aws-amplify

To help you get started, we’ve selected a few aws-amplify 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 dabit3 / react-authentication-in-depth / src / SignIn.js View on Github external
signIn = () => {
    Auth.signIn(this.state.username, this.state.password)
      .then(user => {
        this.setState({ user, showConfirmation: true })
      })
      .catch(err => console.log('error signing in...: ', err))
  }
  confirmSignIn = () => {
github aws-samples / aws-amplify-auth-starters / src / nav / auth / SignIn.js View on Github external
signIn = async () => {
    const { username, password } = this.state
    try {
      await Auth.signIn(username, password)
      console.log('successfully signed in')
      this.props.navigation.navigate('MainNav')
    } catch (err) {
      console.log('error signing up...', err)
    }
  }
  showForgotPassword = () => {
github dabit3 / full-stack-serverless-code / custom-authentication / src / Form.js View on Github external
async function signIn({ username, password }, setUser) {
  try {
    const user = await Auth.signIn(username, password)
    const userInfo = { username: user.username, ...user.attributes }
    setUser(userInfo)
  } catch (err) {
    console.log('error signing up..', err)
  }
}
github pjay79 / MoviesApp / app / screens / SignInScreen.js View on Github external
signIn = async () => {
    this.setState({ loading: true, error: '' });
    const { username, password } = this.state;
    if (username && password) {
      await Auth.signIn(username, password)
        .then((user) => {
          this.setState({ user });
          this.props.navigation.navigate('App');
          console.log(this.state.user);
        })
        .catch((error) => {
          this.setState({ loading: false, error: error.message });
        });
    } else {
      this.setState({ loading: false, error: 'Complete missing fields' });
    }
  };
github codeformilwaukee / DECARCERATION-PLATFORM / web-app / src / components / SignInPage / index.js View on Github external
async function handleSubmit(event) {
    event.preventDefault();
  
    try {
      await Auth.signIn(email, password);
      alert("Logged in");
    } catch (e) {
      alert(e.message);
    }
  }
github aws-amplify / amplify-js / packages / aws-amplify-react-native / dist / Auth / SignIn.js View on Github external
signIn() {
        const { username, password } = this.state;
        logger.debug('Sign In for ' + username);
        Auth.signIn(username, password).then(user => {
            logger.debug(user);
            const requireMFA = user.Session !== null;
            if (user.challengeName === 'SMS_MFA') {
                this.changeState('confirmSignIn', user);
            } else if (user.challengeName === 'NEW_PASSWORD_REQUIRED') {
                logger.debug('require new password', user.challengeParam);
                this.changeState('requireNewPassword', user);
            } else {
                this.checkContact(user);
            }
        }).catch(err => this.error(err));
    }
github aws-amplify / amplify-js / packages / aws-amplify-react-native / src / Auth / Authenticator.js View on Github external
signIn(username, password) {
		const that = this;
		return Auth.signIn(username, password).then(data => {
			that.onStateChange('signedIn');
			return data;
		});
	}
github mzohaibqc / antd-amplify-react / src / SignInForm.js View on Github external
signIn() {
    const { username, password } = this.inputs;
    if (!Auth || typeof Auth.signIn !== "function") {
      throw new Error(
        "No Auth module found, please ensure @aws-amplify/auth is imported"
      );
    }
    this.setState({ loading: true });
    Auth.signIn(username, password)
      .then(user => {
        let loading = false;
        if (
          user.challengeName === "SMS_MFA" ||
          user.challengeName === "SOFTWARE_TOKEN_MFA"
        ) {
          this.changeState("confirmSignIn", user);
        } else if (user.challengeName === "NEW_PASSWORD_REQUIRED") {
          this.changeState("requireNewPassword", user);
        } else if (user.challengeName === "MFA_SETUP") {
          this.changeState("TOTPSetup", user);
        } else {
          loading = true;
          this.checkContact(user);
        }
        if (!loading) {
github aws-amplify / amplify-js / packages / aws-amplify-react-native / dist / Auth / Authenticator.js View on Github external
signIn(username, password) {
        const that = this;
        return Auth.signIn(username, password).then(data => {
            that.onStateChange('signedIn');
            return data;
        });
    }