Advertisement
Guest User

Untitled

a guest
Jul 10th, 2017
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. let authenticationData = {
  2. Username: username,
  3. Password: password,
  4. };
  5. let authenticationDetails = new AWSCognito.CognitoIdentityServiceProvider.AuthenticationDetails(authenticationData);
  6.  
  7. let userData = {
  8. Username: username,
  9. Pool: this.cUtil.getUserPool()
  10. };
  11.  
  12. console.log("Authenticating the user");
  13. let cognitoUser = new AWSCognito.CognitoIdentityServiceProvider.CognitoUser(userData);
  14. cognitoUser.authenticateUser(authenticationDetails, {
  15. onSuccess: function (result) {
  16. var logins = {};
  17. var loginKey = 'cognito-idp.' +
  18. _REGION +
  19. '.amazonaws.com/' +
  20. _USER_POOL_ID;
  21. console.log("identity pool id: " + _IDENTITY_POOL_ID);
  22. console.log("login key: " + loginKey);
  23. console.log("user: " + JSON.stringify(cognitoUser));
  24. logins[loginKey] = result.getIdToken().getJwtToken();
  25. console.log("logins: " + JSON.stringify(logins));
  26. AWS.config.credentials = new AWS.CognitoIdentityCredentials({
  27. 'IdentityPoolId': _IDENTITY_POOL_ID,
  28. 'Logins': logins
  29. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement