解析:无效的用户名,密码 [英] Parse : invalid username, password

查看:177
本文介绍了解析:无效的用户名,密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是使用解析API用于数据库,并试图使用的用户名服务,它提供。据我所知,从教程,为了登录你这样做:

I was using the Parse API for databases and trying to use the username service that it provides. I understand that from the tutorial that in order to login you do this :

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.get code(),以获得错误的发生的类型,但是从本网站的 https://parse.com/docs/android/api/ 我找不到任何错误codeS属于无效的用户名/密码

If the login failed, I was just wondering how I could tell whether it failed because the username typed in was invalid, or the password. I know that you can do e.getCode() to get the type of error that occurred, but from this site https://parse.com/docs/android/api/ I couldn't find any error codes pertaining to invalid username/password

感谢您
詹姆斯

Thank you james

推荐答案

这是我做过什么检查用户名/密码有效期在我的应用程序之一。此法提交反对ParseUser类的查询,如果传递的用户名存在返回true,如果它不那么你知道用户名是有效的。

This is what I did to check username/password validity in one of my applications. This method submits a query against the ParseUser class and returns true if the passed username exists, if it does then you know the username is valid.

(外部检查ParseException.OBJECT_NOT_FOUND - 结合这一点,我们可以告诉用户是否需要注册或有一个无效的密码)

(check externally for ParseException.OBJECT_NOT_FOUND - in conjunction with this we can tell whether the user needs to register or has an invalid password.)

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;
        }
    }

希望这可以帮助别人这个问题。

Hopefully this can help someone with this issue.

这篇关于解析:无效的用户名,密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆