認証されたユーザーに新しいパスワードを設定しようとすると、次の JavaScript エラーが発生し、どこで発生しているのかわかりません。登録機能を呼び出すと、ユーザーは実際に一時パスワードを新しいパスワードで上書きでき、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')
}
})
}