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')
}
})
}
你說得對,我其實只是看着自己的文檔,並得到了它的工作,但感謝的答案 – itsclarke