Guest User

Untitled

a guest
Apr 20th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. //Start: setNewPasswordForAdmin
  2. setNewPasswordForAdmin(username: string, password: string) {
  3.  
  4. //Start: Creating new user with username and pool data
  5. const adminUserdata = {
  6. Username: username,
  7. Pool: userpoolAdmin
  8. }
  9. const adminuser = new CognitoUser(adminUserdata);
  10. //End: Creating new user with username and pool data
  11.  
  12.  
  13. //create attributelist array which will contain all the attributes requried for signing in
  14. //these attributes are those attributes, which are selected while creating user pool on aws
  15. const attributeList : CognitoUserAttribute[] = [];
  16.  
  17. //form a json object containing Name and Value of attribute used
  18. const usernameattribute = {
  19. Name:'username',
  20. Value: username
  21. }
  22.  
  23. //Push list of attributes in the attributeList array
  24. attributeList.push(new CognitoUserAttribute(usernameattribute));
  25. console.log(attributeList);
  26. const that = this;
  27.  
  28. adminuser.completeNewPasswordChallenge(password, attributeList ,{
  29. onFailure(err){
  30.  
  31. console.log(err);
  32. },
  33. onSuccess(result){
  34. console.log(":::::::: Password change successfull ");
  35.  
  36. that.router.navigate(['']);
  37. }
  38. });
  39. }
  40. //End: setNewPasswordForAdmin
Add Comment
Please, Sign In to add comment