Skip to content

Commit

Permalink
Add testing.js
Browse files Browse the repository at this point in the history
  • Loading branch information
tomislacker committed Apr 21, 2016
1 parent 1367836 commit 4ddf502
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<link rel="stylesheet" type="text/css" href="default.css">
<script type="text/javascript" src="amazon-cognito-identity-js/dist/aws-cognito-sdk.js"></script>
<script type="text/javascript" src="amazon-cognito-identity-js/dist/amazon-cognito-identity.min.js"></script>
<script type="text/javascript" src="testing.js"></script>
</head>
<body>
<h1>Example Page</h1>
Expand Down
56 changes: 56 additions & 0 deletions testing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
AWSCognito.config.region = 'us-east-1';
AWSCognito.config.sslEnabled = true;
var poolData = {
// UserPoolId: 'us-east-1:f4dacd7d-1f39-41c7-b5eb-33744d16126a',
// UserPoolId: 'OkR5rVdza',
// UserPoolId: 'us-east-1_OkR5rVdza',
UserPoolId: 'us-east-1:f4dacd7d-1f39-41c7-b5eb-33744d16126a',
ClientId: '377em29vuj7joi6lcso3gu9dgl'
}

var userPool = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserPool(poolData);

var attributeList = [];

var registerAttrs = [
{
Name: 'email',
Value: 'btomasik@telkonet'
},
{
Name: 'family_name',
Value: 'Tomasik'
},
{
Name: 'name',
Value: 'Ben'
},
{
Name: 'phone_number',
Value: '+14143012275'
},
{
Name: 'picture',
Value: 'asdf.jpg'
}]

for (var this_attr_index in registerAttrs)
{
var this_attr = registerAttrs[this_attr_index]
console.log("Registering attribute: " + this_attr['Name'] + ": '" + this_attr['Value'] + "'")
attr = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserAttribute(
this_attr
);
attributeList.push(attr);
}

userPool.signUp('btomasik@telkonet.com', 'MyAwes0m3Password!&', attributeList, null, function(err, result){
if (err) {
console.log('Error Occurred: ' + err);
alert(err);
return;
}
cognitoUser = result.user;
console.log('user name is ' + cognitoUser.getUsername());
});

0 comments on commit 4ddf502

Please sign in to comment.