我直接复制文档的例子来注册,可以成功登录,但是我用自己注册的Tony,就用户名和密码不匹配
代码:
const newUser = {
username: 'Tony',
password: '123@Tony',
email: '1234567@qq.com',
}
function register() {
const user = new AV.User()
user.setUsername(newUser.username);
user.setPassword(newUser.username);
user.setEmail(newUser.email)
user.signUp().then((user) => {
// 注册成功
console.log(注册成功。objectId:${user.id}
);
alert("注册成功")
}, (error) => {
// 注册失败(通常是因为用户名已被使用)
alert("注册失败")
});
}
function login() {
//创建实例
AV.User.logIn(newUser.username, newUser.password).then((user) => {
// 登录成功
alert('登录成功')
console.log(user)
}, (error) => {
// 登录失败(可能是密码错误)
alert(error)
});
}
控制台日志:
leancloud:request request(1) POST https://f3vgoz89.lc-cn-n1-shared.com/1.1/login undefined
Object
password: "123@Tony"
username: "Tony"
proto: Object
Object
Content-Type: "application/json;charset=UTF-8"
X-LC-Id: "f3VGoz89d3QcodkQbgmTrlvf-gzGzoHsz"
X-LC-Session: "utdz196711nc30s8d00ovp165"
X-LC-Sign: "e355f085bf7c0c1ef266aa6e3f65abf8,1588329462617"
X-LC-UA: "LeanCloud-JS-SDK/4.5.3 (Browser)"
proto: Object
+14s
f3vgoz89.lc-cn-n1-shared.com/1.1/login:1 Failed to load resource: the server responded with a status of 400 ()
av-min.js?0631:1 leancloud:request response(1) 400
Object
code: 210
rawMessage: "The username and password mismatch."
proto: Object
undefined +89ms
av-min.js?0631:1 leancloud:request:error response(1) 400
Object
code: 210
rawMessage: "The username and password mismatch."
proto: Object