1

認証されたユーザーを新しいパスワードで設定しようとすると、次のjavascriptエラーが発生し、どこで発生しているのかわかりません。登録機能を呼び出すと、実際には一時パスワードを新しいパスワードで上書きすることができ、すべてがCognitoコンソールで正常に表示されます。また、新しいパスワードでログインすることもできます。未知のエラー:n.onSuccessは機能ではありませんAWS Cognito

Uncaught Error: n.onSuccess is not a function  request.js?1405:31 
    at Response.eval (eval at <anonymous> (app.js:1290), <anonymous>:17:14072) 
    at Request.eval (eval at <anonymous> (app.js:1746), <anonymous>:355:18) 
    at Request.callListeners (eval at <anonymous> (app.js:1056), <anonymous>:105:20) 
    at Request.emit (eval at <anonymous> (app.js:1056), <anonymous>:77:10) 
    at Request.emit (eval at <anonymous> (app.js:1746), <anonymous>:668:14) 
    at Request.transition (eval at <anonymous> (app.js:1746), <anonymous>:22:10) 
    at AcceptorStateMachine.runTo (eval at <anonymous> (app.js:1884), <anonymous>:14:12) 
    at eval (eval at <anonymous> (app.js:1884), <anonymous>:26:10) 
    at Request.eval (eval at <anonymous> (app.js:1746), <anonymous>:38:9) 
    at Request.eval (eval at <anonymous> (app.js:1746), <anonymous>:670:12) 

マイレジスタ機能:

import {Config, CognitoIdentityCredentials} from 'aws-sdk' 
import {CognitoUserPool, CognitoUser, AuthenticationDetails, CognitoUserAttribute} from 'amazon-cognito-identity-js' 

import jwtDecode from 'jwt-decode' 
import store from './store' 

export default class CognitoAuth { 

    register (username, email, pass, newPassword, cb) { 
    let authenticationDetails = new AuthenticationDetails({ 
     Username: username, 
     Password: pass 
    }) 
    let cognitoUser = new CognitoUser({ 
     Username: username, 
     Pool: this.userPool 
    }) 

    cognitoUser.authenticateUser(authenticationDetails, { 
     newPasswordRequired: (userAttributes, requiredAttributes) => { 

     // the api doesn't accept this field back 
     delete userAttributes.email_verified 

     cognitoUser.completeNewPasswordChallenge(newPassword, userAttributes, this) 
     } 
    }) 
    } 
} 

Register.vue

signup() { 
    this.$cognitoAuth.register(this.username, this.email, this.oldPass, this.newPass, (err, result) => { 
    if (err) { 
     this.error = true 
     this.errMsg = err.message 
     console.error(err) 
    } else { 
     console.log('Login Successful:', result) 
     this.$router.replace(this.$route.query.redirect || '/search') 
    } 
    }) 
} 

答えて

2

あなたは新しいセッションでの成功に呼び出されたonSuccessコールバックの実装を、逃しています。 CognitoUser.jsの341行を参照してください。例えば

. 
. 
. 
cognitoUser.authenticateUser(authenticationDetails, { 
    onSuccess: (result) => { 
     // User authentication was successful. 
    }, 

    onFailure: (err) => { 
     // User authentication was not successful. 
    }, 

    mfaRequired: (codeDeliveryDetails) => { 
     // MFA is required to complete user authentication. 
     // Get the code from user and call: 
     cognitoUser.sendMFACode(mfaCode, this) 
    }, 

    newPasswordRequired: (userAttributes, requiredAttributes) => { 

     // the api doesn't accept this field back 
     delete userAttributes.email_verified; 

     cognitoUser.completeNewPasswordChallenge(newPassword, userAttributes, this); 
    } 
}) 
. 
. 
. 
+0

そうだね、私は実際にちょうど彼らのドキュメントを見ていたし、それが働いてしまったが、答えてくれてありがとう – itsclarke

関連する問題