title: Angular 6 AWS Cognito How to Handle newPasswordRequired
body: <p>I am completely at a loss here. I have been struggling with this for several hours now trying multiple different approaches and none are getting me anywhere. My problem is I cannot seem to figure out how it the new Password is meant to be retrieved from the user within the newPasswordRequired callback after an authentication request to Cognito. Here is my code in its current state. Please don't hesitate to tell me what I can do better, as I am fairly new to Angular and completely new to using Cognito authentication.</p>
  
  <pre><code>public login(email: string, password: string): Observable&lt;UserModel&gt; {
          const cognitoUser = new CognitoUser(this.getUserData(email));
          cognitoUser.setAuthenticationFlowType('USER_PASSWORD_AUTH');
          const authenticationDetails = new AuthenticationDetails(CognitoUtils.getAuthDetails(email, password));
          const self = this;
          return Observable.create((obs: Observer&lt;UserModel&gt;) =&gt; {
              cognitoUser.authenticateUser(authenticationDetails, {
                  onSuccess: result =&gt; {
                      this.session = result;
                      const token = result.getIdToken();
                      const accessToken = result.getAccessToken();
                      this.localStorage.setToken(token);
                      this.localStorage.setAccessToken(accessToken);
                      obs.complete();
                  },
                  onFailure: err =&gt; {
                      obs.error(err);
                  },
                  newPasswordRequired: (userAttributes, requiredAttributes) =&gt; {
                      let dialogRef: MatDialogRef&lt;NewPasswordComponent&gt;;
                      const config = new MatDialogConfig();;
                      config.role = 'dialog';
                      config.width = '40%';
                      config.data = { newPass: self.newPass };
                      dialogRef = self.dialog.open(NewPasswordComponent, config);
  
                      dialogRef.afterClosed().subscribe(result =&gt; {
                          self.newPass = result;
                          cognitoUser.completeNewPasswordChallenge(self.newPass, userAttributes, {
                              onSuccess: result =&gt; {
                                  obs.complete();
                              },
                              onFailure: err =&gt; {
                                  obs.error(err);
                              }
                          });
                      });
                  }
              });
          });
      }
  </code></pre>