-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.js
32 lines (31 loc) · 890 Bytes
/
user.js
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
/* eslint-disable import/no-extraneous-dependencies */
const AWS = require('aws-sdk');
module.exports.disable = (e, ctx, cb) => {
const cognito = new AWS.CognitoIdentityServiceProvider();
const ses = new AWS.SES();
cognito.adminDisableUser({ UserPoolId: e.userPoolId, Username: e.request.userAttributes.email })
.promise()
.then(() => ses.sendEmail(
{
Source: process.env.ADMIN_EMAIL,
Destination: {
ToAddresses: [process.env.ADMIN_EMAIL],
},
Message: {
Body: {
Text: {
Charset: 'UTF-8',
Data: `Verify user ${e.request.userAttributes.email}`,
},
},
Subject: {
Charset: 'UTF-8',
Data: 'DropBucket user requires activation',
},
},
},
).promise())
.then(() => {
cb(null, e);
});
};