Add user sign-up

  1. Add HTML layout for sign-up
<div id="signup" class="w3-container w3-padding-large w3-grey tab">
    <div class="w3-section">
      <label>Name</label>
      <input class="w3-input w3-border" type="text" id="signup_name" required>
    </div>
    <div class="w3-section">
      <label>Username</label>
      <input class="w3-input w3-border" type="text" id="signup_username" required>
    </div>
    <div class="w3-section">
      <label>Email</label>
      <input class="w3-input w3-border" type="text" id="signup_email" required>
    </div>
    <div class="w3-section">
      <label>Phone</label>
      <input class="w3-input w3-border" type="text" id="signup_phone" required>
    </div>
    <div class="w3-section">
      <label>Password</label>
      <input class="w3-input w3-border" type="password" id="signup_password" required>
    </div>
    <button type="submit" class="w3-button w3-black w3-margin-bottom" onclick="signUp()">Sign Up</button>
</div>
  1. Add JS signUp function to JavaScript tab
/**
 * Add Sign Up
 */
function signUp(){

    var email = $("#signup_email").val();
    var username = $("#signup_username").val();
    var password = $("#signup_password").val();
    var name = $("#signup_name").val();
    var phone = $("#signup_phone").val();

    var attributeList = [];

    var dataEmail = { Name: 'email', Value: email };
    var dataPhone = {Name: 'phone_number', Value: phone };
    var dataName = {Name: 'name', Value: name};

    var attributeEmail = new AmazonCognitoIdentity.CognitoUserAttribute(dataEmail);
    var attributeName = new AmazonCognitoIdentity.CognitoUserAttribute(dataName);
    var attributePhone = new AmazonCognitoIdentity.CognitoUserAttribute(dataPhone);

    attributeList.push(attributeEmail);
    attributeList.push(attributeName);
    attributeList.push(attributePhone);

    userPool.signUp(username, password, attributeList, null, function(err, result ) {
      if (err) {
        console.log(err.message || JSON.stringify(err));
        return;
      }else{
      	console.log("Success:"+result);

        var cognitoUser = result.user;
        var confirmationCode = prompt("Please enter confirmation code:");

        cognitoUser.confirmRegistration(confirmationCode, true, function(err, result) {
          if (err) {
            alert(err.message || JSON.stringify(err));
            return;
          }
          console.log('call result: ' + result);
        });
      }
    });
}
  1. By now, you should be able to sign-up a new user