-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.js
39 lines (25 loc) · 901 Bytes
/
login.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
33
34
35
36
37
const AWSCognito = require("amazon-cognito-identity-js");
var poolData = {
UserPoolId: "", // Your user pool id here
ClientId: "" // Your client id here
};
var userPool = new AWSCognito.CognitoUserPool(poolData);
exports.Login = (event, context, callback) => {
var username = event.username;
var password = event.password
var authenticationData = {
Username: username, // your username here
Password: password, // your password here
};
var authenticationDetails = new AWSCognito.AuthenticationDetails(authenticationData);
var userData = {
Username: username,
Pool: userPool
}
var cognitoUser = new AWSCognito.CognitoUser(userData);
cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: function (result) {
callback(null, result.getAccessToken().getJwtToken())
}
})
};