我已将AWS Cognito用于注册功能。我已经提到了以下链接
https://github.com/aws/amazon-cognito-identity-js/blob/master/README.md
我已包含这些文件
var AmazonCognitoIdentity = require('amazon-cognito-identity-js');
var CognitoUserPool = AmazonCognitoIdentity.CognitoUserPool;
当我使用下面的代码时,它会出现上述错误
var attributeEmail = new
AWSCognito.CognitoIdentityServiceProvider.CognitoUserAttribute(dataEmail);
这是users.js文件,其中包含上述代码
var express = require('express');
var router = express.Router();
/* GET users listing. */
router.get('/', function(req, res, next) {
var AmazonCognitoIdentity = require('amazon-cognito-identity-js');
var CognitoUserPool = AmazonCognitoIdentity.CognitoUserPool;
var firstName = req.query.name;
var lastName = req.query.familyName;
var email = req.query.email;
var phoneNumber = req.query.phoneNumber;
var address = req.query.address;
var poolData = {
UserPoolId : '-----', // Your user pool id here
ClientId : '----' // Your client id here
};
var userPool = new CognitoUserPool(poolData);
var attributeList = [];
var dataEmail = {
Name : 'email',
Value : email
};
var dataPhoneNumber = {
Name : 'phone_number',
Value : phoneNumber
};
var dataName = {
Name : 'name',
Value : firstName
};
var dataFamilyName = {
Name : 'family_name',
Value : lastName
};
var dataAddress = {
Name : 'address',
Value : address
};
var username = firstName.concat(lastName);
var password = Math.floor((Math.random() * 100) + 1);
var attributeEmail = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserAttribute(dataEmail);
var attributePhoneNumber = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserAttribute(dataPhoneNumber;
var attributeName = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserAttribute(dataName);
var attributeFamilyName = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserAttribute(dataFamilyName);
var attributeAddress = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserAttribute(dataAddress);
attributeList.push(attributeEmail);
attributeList.push(attributePhoneNumber);
attributeList.push(attributeName);
attributeList.push(attributeFamilyName);
attributeList.push(attributeAddress);
userPool.signUp(username, password, attributeList, null, function(err, result){
if (err) {
alert(err);
return;
}
cognitoUser = result.user;
console.log('user name is ' + cognitoUser.getUsername());
});
res.send('respond with a resource');
});
module.exports = router;
如果有人可以帮助我真的很棒。提前谢谢。