How to use the aws-amplify.Auth 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 aws-amplify / amplify-js / packages / aws-amplify-react / dist / Widget / TOTPSetupComp.js View on Github external
value: function verifyTotpToken() {
            var _this3 = this;

            if (!this.inputs) {
                logger.debug('no input');
                return;
            }
            var user = this.props.authData;
            var totpCode = this.inputs.totpCode;

            _awsAmplify.Auth.verifyTotpToken(user, totpCode).then(function () {
                // set it to preferred mfa
                _awsAmplify.Auth.setPreferredMFA(user, 'TOTP');
                _this3.setState({ setupMessage: 'Setup TOTP successfully!' });
                logger.debug('set up totp success!');
                _this3.triggerTOTPEvent('Setup TOTP', 'SUCCESS', user);
            }).catch(function (err) {
                _this3.setState({ setupMessage: 'Setup TOTP failed!' });
                logger.error(err);
            });
        }
    }, {
github aws-amplify / amplify-js / packages / aws-amplify-react / dist / Auth / TOTPSetup.js View on Github external
value: function checkContact(user) {
            var _this2 = this;

            _awsAmplify.Auth.verifiedContact(user).then(function (data) {
                if (!_awsAmplify.JS.isEmpty(data.verified)) {
                    _this2.changeState('signedIn', user);
                } else {
                    user = Object.assign(user, data);
                    _this2.changeState('verifyContact', user);
                }
            });
        }
    }, {
github aws-amplify / amplify-js / packages / aws-amplify-react / dist / Auth / MFASetup.js View on Github external
function setup() {
                var _this2 = this;

                var user = this.props.authData;
                _awsAmplify.Auth.setupTOTP(user).then(function (data) {
                    logger.debug('secret key', data);
                    var code = "otpauth://totp/AWSCognito:" + user.username + "?secret=" + data + "&issuer=AWSCognito";
                    _this2.setState({ code: code });
                })['catch'](function (err) {
                    return logger.debug('mfa setup failed', err);
                });
            }
github aws-amplify / amplify-js / packages / aws-amplify-react / dist / Auth / SignUp.js View on Github external
value: function signUp() {
            var _this2 = this;

            var _inputs = this.inputs,
                username = _inputs.username,
                password = _inputs.password,
                email = _inputs.email,
                phone_number = _inputs.phone_number;

            _awsAmplify.Auth.signUp(username, password, email, phone_number).then(function () {
                return _this2.changeState('confirmSignUp', username);
            }).catch(function (err) {
                return _this2.error(err);
            });
        }
    }, {
github aws-amplify / amplify-js / packages / aws-amplify-react / dist / Auth / RequireNewPassword.js View on Github external
value: function change() {
            var _this3 = this;

            var user = this.props.authData;
            var password = this.inputs.password;
            var requiredAttributes = user.challengeParam.requiredAttributes;

            _awsAmplify.Auth.completeNewPassword(user, password, requiredAttributes).then(function (user) {
                logger.debug('complete new password', user);
                if (user.challengeName === 'SMS_MFA') {
                    _this3.changeState('confirmSignIn', user);
                } else if (user.challengeName === 'MFA_SETUP') {
                    logger.debug('TOTP setup', user.challengeParam);
                    _this3.changeState('TOTPSetup', user);
                } else {
                    _this3.checkContact(user);
                }
            }).catch(function (err) {
                return _this3.error(err);
            });
        }
    }, {
github aws-amplify / amplify-js / packages / aws-amplify-react / dist / Widget / MFASetupComp.js View on Github external
function setup() {
                var _this2 = this;

                this.setState({ setupMessage: null });
                var user = this.props.authData;
                _awsAmplify.Auth.setupTOTP(user).then(function (data) {
                    logger.debug('secret key', data);
                    var code = "otpauth://totp/AWSCognito:" + user.username + "?secret=" + data + "&issuer=AWSCognito";
                    _this2.setState({ code: code });
                })['catch'](function (err) {
                    return logger.debug('mfa setup failed', err);
                });
            }
github aws-amplify / amplify-js / packages / aws-amplify-react / dist / Auth / ConfirmSignIn.js View on Github external
value: function confirm() {
            var _this3 = this;

            var user = this.props.authData;
            var code = this.inputs.code;

            var mfaType = user.challengeName === 'SOFTWARE_TOKEN_MFA' ? 'SOFTWARE_TOKEN_MFA' : null;
            _awsAmplify.Auth.confirmSignIn(user, code, mfaType).then(function () {
                _this3.checkContact(user);
            }).catch(function (err) {
                return _this3.error(err);
            });
        }
    }, {
github aws-amplify / amplify-js / packages / aws-amplify-react / dist / Auth / RequireNewPassword.js View on Github external
value: function checkContact(user) {
            var _this2 = this;

            _awsAmplify.Auth.verifiedContact(user).then(function (data) {
                if (!_awsAmplify.JS.isEmpty(data.verified)) {
                    _this2.changeState('signedIn', user);
                } else {
                    user = Object.assign(user, data);
                    _this2.changeState('verifyContact', user);
                }
            });
        }
    }, {
github aws-amplify / amplify-js / packages / aws-amplify-react / dist / Auth / Provider / withFacebook.js View on Github external
fb.api('/me', function (response) {
                    var user = {
                        name: response.name
                    };

                    _awsAmplify.Auth.federatedSignIn('facebook', { token: accessToken, expires_at: expires_at }, user).then(function (credentials) {
                        if (onStateChange) {
                            onStateChange('signedIn');
                        }
                    });
                });
            }