in source/resources/helper/lib/cognito-helper.js [42:137]
cognitoHelper.prototype.createDataLakeUserPool = function(cb) {
let _userPoolId = '';
let cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();
let params = {
PoolName: 'data-lake',
AliasAttributes: ['email'],
AutoVerifiedAttributes: ['email']
};
cognitoidentityserviceprovider.createUserPool(params, function(err, data) {
if (err) {
return cb(err, null);
}
_userPoolId = data.UserPool.Id;
let params = {
CustomAttributes: [{
AttributeDataType: 'String',
DeveloperOnlyAttribute: false,
Mutable: true,
Name: 'display_name',
Required: false,
StringAttributeConstraints: {
MaxLength: '256',
MinLength: '1'
}
}, {
AttributeDataType: 'String',
DeveloperOnlyAttribute: false,
Mutable: true,
Name: 'role',
Required: false,
StringAttributeConstraints: {
MaxLength: '256',
MinLength: '1'
}
}, {
AttributeDataType: 'String',
DeveloperOnlyAttribute: false,
Mutable: true,
Name: 'accesskey',
Required: false,
StringAttributeConstraints: {
MaxLength: '256',
MinLength: '1'
}
}, {
AttributeDataType: 'String',
DeveloperOnlyAttribute: false,
Mutable: true,
Name: 'secretaccesskey',
Required: false,
StringAttributeConstraints: {
MaxLength: '512',
MinLength: '1'
}
}],
UserPoolId: _userPoolId
};
cognitoidentityserviceprovider.addCustomAttributes(params, function(err, newAttrData) {
if (err) {
return cb(err, null);
}
let params = {
ClientName: 'data-lake-ui',
UserPoolId: _userPoolId,
GenerateSecret: false,
RefreshTokenValidity: 1,
ReadAttributes: [
'email',
'custom:display_name',
'custom:role',
'custom:accesskey'
],
WriteAttributes: [
'phone_number',
'email'
]
};
cognitoidentityserviceprovider.createUserPoolClient(params, function(
err,
newClientData) {
if (err) {
return cb(err, null);
}
return cb(null, {
UserPoolId: _userPoolId,
UserPoolClientId: newClientData.UserPoolClient.ClientId
});
});
});
});
};