-
Notifications
You must be signed in to change notification settings - Fork 2
/
vineet-medium-cognitio-signup
93 lines (71 loc) · 2.2 KB
/
vineet-medium-cognitio-signup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
const AmazonCognitoIdentity = require('amazon-cognito-identity-js');
const CognitoUserPool = AmazonCognitoIdentity.CognitoUserPool;
var poolData = {
UserPoolId: 'us-east-1_xxxxxxx08', // Your user pool id here
ClientId: 'xxxxxxxxxxxxxxxxxxx', // Your client id here
};
var userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData);
var attributeList = [];
var dataEmail = {
Name: 'email',
Value: '[email protected]',
};
var dataPhoneNumber = {
Name: 'phone_number',
Value: '+910000000000',
};
var adddress = {
Name: 'address',
Value: 'abc india',
};
var gender = {
Name: 'gender',
Value: 'male',
};
var birthdate = {
Name: 'birthdate',
Value: '1941-10-25',
};
var userName = {
Name: 'name',
Value: 'vineet karandikar',
};
var attributeEmail = new AmazonCognitoIdentity.CognitoUserAttribute(dataEmail);
var attributePhoneNumber = new AmazonCognitoIdentity.CognitoUserAttribute(
dataPhoneNumber
);
var attributeAddress = new AmazonCognitoIdentity.CognitoUserAttribute(adddress);
var attributeGender = new AmazonCognitoIdentity.CognitoUserAttribute(gender);
var attributeBirthdate = new AmazonCognitoIdentity.CognitoUserAttribute(birthdate);
var attributeName = new AmazonCognitoIdentity.CognitoUserAttribute(userName);
attributeList.push(attributeName);
attributeList.push(attributeEmail);
attributeList.push(attributePhoneNumber);
attributeList.push(attributeAddress);
attributeList.push(attributeGender);
attributeList.push(attributeBirthdate);
async function cognitioSignUp() {
return new Promise((resolve, reject) => {
userPool.signUp('[email protected]', 'xxxxxxxxx!', attributeList, null, function (
err,
result
) {
if (err) {
console.log(err.message || JSON.stringify(err));
reject(err.message);
} else {
console.log('call result: ' + result);
resolve(result);
}
});
});
}
exports.handler = async (event) => {
let result = await cognitioSignUp();
console.log(result);
const response = {
statusCode: 200,
body: JSON.stringify('Hello from Lambda!'),
};
return response;
};