How to use the amazon-cognito-identity-js.CognitoUserAttribute function in amazon-cognito-identity-js

To help you get started, we’ve selected a few amazon-cognito-identity-js 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 kangzeroo / Kangzeroos-Complete-AWS-Web-Boilerplate / App / src / api / aws / aws_cognito.js View on Github external
const p = new Promise((res, rej)=>{
		// we create an array for our attributes that we want to update, and push all `CognitoUserAttribute` objects into it
		const attributeList = []
		// loop through the `attrs` array to create our `CognitoUserAttribute` objects
		for(let a = 0; a
github kangzeroo / Kangzeroos-Complete-AWS-Web-Boilerplate / Boilerplate_Frontend / App / src / api / aws / aws_cognito.js View on Github external
const p = new Promise((res, rej)=>{
		// we create an array for our attributes that we want to update, and push all `CognitoUserAttribute` objects into it
		const attributeList = []
		// loop through the `attrs` array to create our `CognitoUserAttribute` objects
		for(let a = 0; a
github jkettmann / universal-react-relay-starter-kit / server / graphql / auth / register.js View on Github external
return new Promise((resolve, reject) => {
    const dataEmail = { Name: 'email', Value: email }
    const dataFirstName = { Name: 'given_name', Value: firstName }
    const dataLastName = { Name: 'family_name', Value: lastName }

    const attributeList = [
      new CognitoUserAttribute(dataEmail),
      new CognitoUserAttribute(dataFirstName),
      new CognitoUserAttribute(dataLastName),
    ]

    userPool.signUp(email, password, attributeList, null, (error, result) => {
      log(error, result)
      if (error) {
        // TODO this code shouldn't know about graphql errors. refactor to use separate layers
        if (error.code === 'UsernameExistsException') {
          reject(new UserError(ERRORS.EmailAlreadyTaken))
        } else {
          reject(error)
        }
        return
      }
      resolve({ id: result.userSub, email })
    })
github jkettmann / universal-react-relay-starter-kit / server / graphql / auth / register.js View on Github external
return new Promise((resolve, reject) => {
    const dataEmail = { Name: 'email', Value: email }
    const dataFirstName = { Name: 'given_name', Value: firstName }
    const dataLastName = { Name: 'family_name', Value: lastName }

    const attributeList = [
      new CognitoUserAttribute(dataEmail),
      new CognitoUserAttribute(dataFirstName),
      new CognitoUserAttribute(dataLastName),
    ]

    userPool.signUp(email, password, attributeList, null, (error, result) => {
      log(error, result)
      if (error) {
        // TODO this code shouldn't know about graphql errors. refactor to use separate layers
        if (error.code === 'UsernameExistsException') {
          reject(new UserError(ERRORS.EmailAlreadyTaken))
        } else {
          reject(error)
        }
        return
      }
      resolve({ id: result.userSub, email })
github timroesner / WeMart / src / SignUp.js View on Github external
poolData = require('./poolData').poolData;
    } else {
        poolData = {
        UserPoolId : process.env.REACT_APP_Auth_UserPoolId,
        ClientId : process.env.REACT_APP_Auth_ClientId
      };
    }
    var userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData);

    var attributeList = [];

    var dataEmail = {
        Name : 'email',
        Value : model.email
    };
    var attributeEmail = new AmazonCognitoIdentity.CognitoUserAttribute(dataEmail);
    attributeList.push(attributeEmail);

    // Necessary becuase the closure has no access to this.props
    let nestedProp = this.props;
    let self = this

    userPool.signUp(model.email, model.password, attributeList, null, function(err, result) {
        if (err) {
          toast.warn(err.message, {
            position: "top-center",
            autoClose: 4000,
            hideProgressBar: false,
            closeOnClick: true,
            pauseOnHover: true,
            draggable: true,
            });
github frsechet / cognito-user-pool / src / methods / profileEdit.js View on Github external
attributes.forEach((item) => {

      // if the attribute concerns the phone number
        if (item.Name === 'phone_number') {
        // do nothing, rather use profileEditPhoneNumber
        // as there are some additionals checks concerning MFA to perform
        }

        // if the attribute has a value, update it with the new value
        else if (item.Value !== null) {
          const attribute = new AmazonCognitoIdentity.CognitoUserAttribute(item);
          attributeUpdateList.push(attribute);
        }

        // otherwise, delete the attribute for that user
        else {
          attributeDeleteList.push(item.Name);
        }
      });
    }
github awslabs / aws-cognito-angular-quickstart / src / app / service / user-registration.service.ts View on Github external
register(user: RegistrationUser, callback: CognitoCallback): void {
        console.log("UserRegistrationService: user is " + user);

        let attributeList = [];

        let dataEmail = {
            Name: 'email',
            Value: user.email
        };
        let dataNickname = {
            Name: 'nickname',
            Value: user.name
        };
        attributeList.push(new CognitoUserAttribute(dataEmail));
        attributeList.push(new CognitoUserAttribute(dataNickname));
        attributeList.push(new CognitoUserAttribute({
            Name: 'phone_number',
            Value: user.phone_number
        }));

        this.cognitoUtil.getUserPool().signUp(user.email, user.password, attributeList, null, function (err, result) {
            if (err) {
                callback.cognitoCallback(err.message, null);
            } else {
                console.log("UserRegistrationService: registered user is " + result);
                callback.cognitoCallback(null, result);
            }
        });

    }
github aws-samples / deploy-manage-microservices-on-ecs-and-fargate / user-profile-service / user-profile-service-code / routes / users.js View on Github external
var dataEmail = {
            Name: 'email',
            Value: data.email
        };
        var dataFirstName = {
            Name: 'given_name',
            Value: data.first_name
        };
        var dataLastName = {
            Name: 'family_name',
            Value: data.last_name
        };

        var attributeEmail = new CognitoUserAttribute(dataEmail);
        var attributeFN = new CognitoUserAttribute(dataFirstName);
        var attributeLN = new CognitoUserAttribute(dataLastName);
        attributeList.push(attributeEmail);
        attributeList.push(attributeFN);
        attributeList.push(attributeLN);

        userPool.signUp(data.email, data.password, attributeList, null, function(err, result) {
            if (err) {
                console.log("Error ", err);
                res.status(500).json({
                    status: 'error',
                    message: err.message
                })
            } else {
                var cognitoUser = result.user;
                res.json({
                    status: 'success',
                    message: cognitoUser.getUsername()
github awslabs / aws-cognito-angular-quickstart / src / app / service / user-registration.service.ts View on Github external
register(user: RegistrationUser, callback: CognitoCallback): void {
        console.log("UserRegistrationService: user is " + user);

        let attributeList = [];

        let dataEmail = {
            Name: 'email',
            Value: user.email
        };
        let dataNickname = {
            Name: 'nickname',
            Value: user.name
        };
        attributeList.push(new CognitoUserAttribute(dataEmail));
        attributeList.push(new CognitoUserAttribute(dataNickname));
        attributeList.push(new CognitoUserAttribute({
            Name: 'phone_number',
            Value: user.phone_number
        }));

        this.cognitoUtil.getUserPool().signUp(user.email, user.password, attributeList, null, function (err, result) {
            if (err) {
                callback.cognitoCallback(err.message, null);
            } else {
                console.log("UserRegistrationService: registered user is " + result);
                callback.cognitoCallback(null, result);
            }
        });

    }
github PacktPublishing / Building-Serverless-Web-Applications / Chapter09 / serverless-store-chap9 / frontend / src / lib / services.js View on Github external
static signup(email, password, callback) {
        const userPool = new CognitoUserPool({
            UserPoolId: config.cognito.USER_POOL_ID,
            ClientId: config.cognito.APP_CLIENT_ID
        });

        const attributeEmail = [
            new CognitoUserAttribute({ 
                Name: 'email', 
                Value: email 
            })
        ];

        userPool.signUp(email, password, attributeEmail, null, callback);
    }