gpt4 book ai didi

android - 解析: invalid username,密码

转载 作者:太空宇宙 更新时间:2023-11-03 12:37:07 24 4
gpt4 key购买 nike

我正在为数据库使用 Parse API,并尝试使用它提供的用户名服务。我从教程中了解到,为了登录,您需要这样做:

ParseUser.logInInBackground("Jerry", "showmethemoney", new LogInCallback() {
public void done(ParseUser user, ParseException e) {
if (user != null) {
// Hooray! The user is logged in.
} else {
// Signup failed. Look at the ParseException to see what happened.
}
}
});

如果登录失败,我只是想知道如何判断登录失败是因为输入的用户名无效,还是因为密码无效。我知道您可以执行 e.getCode() 来获取发生的错误类型,但是从这个站点 https://parse.com/docs/android/api/我找不到任何与无效用户名/密码有关的错误代码

谢谢詹姆斯

最佳答案

这是我在我的一个应用程序中检查用户名/密码有效性所做的。此方法提交针对 ParseUser 类的查询,如果传递的用户名存在,则返回 true,如果存在,则您知道用户名有效。

(从外部检查 ParseException.OBJECT_NOT_FOUND - 结合此我们可以判断用户是否需要注册或密码无效。)

public boolean queryCredentials(String username) {
ParseQuery<ParseUser> queryuserlist = ParseUser.getQuery();
queryuserlist.whereEqualTo("username", username);
try {
//attempt to find a user with the specified credentials.
return (queryuserlist.count() != 0) ? true : false;
} catch (ParseException e) {
return false;
}
}

希望这可以帮助解决这个问题的人。

关于android - 解析: invalid username,密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16534312/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com