2017-11-10 30 views
0

thisの回答に続き、引き続きパスワードを忘れたオプションを実装しようとしましたが、やりました。プロパティが未定義のmakeUnauthenticatedRequestを読み取ることができません

let cognitoUser = new AWSCognito.CognitoIdentityServiceProvider.CognitoUser({ 
    'Username': username, 
    'Pool': aws_user_pools_id 
}); 
cognitoUser.forgotPassword(... 

しかし、私はすぐにこのエラーで打たれた:

Cannot read property 'makeUnauthenticatedRequest' of undefined 

makeUnauthenticatedRequestは(私は実際にアクセスすることはできません)AWSCognito関数内で呼ばれています。

forgotPassword(callback) { 
    this.client.makeUnauthenticatedRequest('forgotPassword' ... 

私はAWSはthis.clientを設定することができるように、私は何かが欠けてると思いますが、私は彼に、正しいIDを与えますか..?

答えて

2

私はそれがCognitoUserPoolオブジェクトである場合に「プール」は、CognitoプールID(string)であったと仮定問題は

let cognitoUser = new AWSCognito.CognitoIdentityServiceProvider.CognitoUser({ 
     'Username': username, 
     'Pool': aws_user_pools_id //HERE 
    }); 

から来たが分かりました。私は何をしなければならなかったことはCognitoUserPoolオブジェクトを作成することでした

getUserPool() { 
    return new AWSCognito.CognitoIdentityServiceProvider.CognitoUserPool({ 
     "UserPoolId": aws_user_pools_id, 
     "ClientId": aws_user_pools_web_client_id 
    }); 
    } 

そして、このCognitoUserPoolオブジェクト

reset_password(username) { 
    let cognitoUser = new AWSCognito.CognitoIdentityServiceProvider.CognitoUser({ 
    'Username': username, 
    'Pool': this.getUserPool() 
    }); 
    ... 
} 
でCognitoUserを作成
関連する問題