Android:ParseException:无效的登录凭据
Android: ParseException: Invalid Login Credentials
我正在编写一个 Android
应用程序,用于将用户注册到 Parse
平台并允许用户注册并登录该应用程序。我可以毫无问题地注册用户。但是,当我在 Parse 中检查我的 _User table 时,它说密码未定义。另外,当我登录时,它会显示
-com.parse.ParseException: 登录凭据无效
这是注册用户的代码
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_up);
//initialize parse with credentials
register = (Button) findViewById(R.id.bSignUpConfirm);
register.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
registerUser();
}
});
ActionBar signUpActionBar = getActionBar();
signUpActionBar.setBackgroundDrawable(new ColorDrawable(Color.RED));
}
public void registerUser(){
getSignUpName = (EditText) findViewById(R.id.eGetSignUpName);
getSignUpUsername = (EditText) findViewById(R.id.eGetSignUpUsername);
getSignUpEmail = (EditText) findViewById(R.id.eGetSignUpEmail);
getSignUpPassword = (EditText) findViewById(R.id.eGetSignUpPassword);
getSignUpConfirmPassword = (EditText) findViewById(R.id.eGetSignUpConfirmPassword);
signUpUsername = getSignUpUsername.getText().toString();
signUpName = getSignUpName.getText().toString();
signUpEmail = getSignUpEmail.getText().toString();
signUpPassword = getSignUpPassword.getText().toString();
signUpConfirmPassword = getSignUpConfirmPassword.getText().toString();
ParseUser newUser = new ParseUser();
newUser.setUsername(signUpUsername);
newUser.setEmail(signUpEmail);
newUser.put("fullName", signUpName);
if(signUpPassword.equals(signUpConfirmPassword)){
newUser.setPassword(signUpPassword);
}else{
Toast.makeText(getApplicationContext(), "Password does not match!", Toast.LENGTH_LONG).show();
}
newUser.signUpInBackground(new SignUpCallback() {
@Override
public void done(com.parse.ParseException e) {
if (e == null){
Intent finishRegistration = new Intent(SignUpActivity.this, MainScreen.class);
startActivity(finishRegistration);
}else{
Toast.makeText(getApplicationContext(), "Connection to the server has failed.\n Please try again later.", Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
});
}
这是登录用户的代码
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
ActionBar loginBar = getActionBar();
loginBar.setTitle("Sign In");
loginBar.setBackgroundDrawable(new ColorDrawable(Color.RED));
//initialize parse credentials
Button logIn = (Button) findViewById(R.id.bSignIn);
logIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
logIn();
}
});
}
public void logIn(){
getLoginUsername = (EditText) findViewById(R.id.eGetLoginUsername);
getLoginPassword = (EditText) findViewById(R.id.eGetLoginUsername);
loginUsername = getLoginUsername.getText().toString();
loginPassword= getLoginPassword.getText().toString();
ParseUser.logInInBackground(loginUsername, loginPassword, new LogInCallback() {
public void done(ParseUser user, ParseException e) {
if (e == null) {
loginSuccessful();
} else {
Toast.makeText(getApplicationContext(),"Wrong Email/Password Combination", Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
});
}
public void loginSuccessful(){
Intent backToMainIntent = new Intent(LoginActivity.this, MainScreen.class);
startActivity(backToMainIntent);
}
谢谢!
Parse 仪表板上的密码值始终未定义,以阻止您查看用户密码。
我认为它不起作用,因为您的登录代码中存在错误。
getLoginUsername = (EditText) findViewById(R.id.eGetLoginUsername);
getLoginPassword = (EditText) findViewById(R.id.eGetLoginUsername);
这两个 EditText 是相同的,尽管一个用于密码而另一个用于用户名。我猜密码 EditText 的 ID 是错误的。
希望对您有所帮助。
我正在编写一个 Android
应用程序,用于将用户注册到 Parse
平台并允许用户注册并登录该应用程序。我可以毫无问题地注册用户。但是,当我在 Parse 中检查我的 _User table 时,它说密码未定义。另外,当我登录时,它会显示
-com.parse.ParseException: 登录凭据无效
这是注册用户的代码
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_up);
//initialize parse with credentials
register = (Button) findViewById(R.id.bSignUpConfirm);
register.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
registerUser();
}
});
ActionBar signUpActionBar = getActionBar();
signUpActionBar.setBackgroundDrawable(new ColorDrawable(Color.RED));
}
public void registerUser(){
getSignUpName = (EditText) findViewById(R.id.eGetSignUpName);
getSignUpUsername = (EditText) findViewById(R.id.eGetSignUpUsername);
getSignUpEmail = (EditText) findViewById(R.id.eGetSignUpEmail);
getSignUpPassword = (EditText) findViewById(R.id.eGetSignUpPassword);
getSignUpConfirmPassword = (EditText) findViewById(R.id.eGetSignUpConfirmPassword);
signUpUsername = getSignUpUsername.getText().toString();
signUpName = getSignUpName.getText().toString();
signUpEmail = getSignUpEmail.getText().toString();
signUpPassword = getSignUpPassword.getText().toString();
signUpConfirmPassword = getSignUpConfirmPassword.getText().toString();
ParseUser newUser = new ParseUser();
newUser.setUsername(signUpUsername);
newUser.setEmail(signUpEmail);
newUser.put("fullName", signUpName);
if(signUpPassword.equals(signUpConfirmPassword)){
newUser.setPassword(signUpPassword);
}else{
Toast.makeText(getApplicationContext(), "Password does not match!", Toast.LENGTH_LONG).show();
}
newUser.signUpInBackground(new SignUpCallback() {
@Override
public void done(com.parse.ParseException e) {
if (e == null){
Intent finishRegistration = new Intent(SignUpActivity.this, MainScreen.class);
startActivity(finishRegistration);
}else{
Toast.makeText(getApplicationContext(), "Connection to the server has failed.\n Please try again later.", Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
});
}
这是登录用户的代码
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
ActionBar loginBar = getActionBar();
loginBar.setTitle("Sign In");
loginBar.setBackgroundDrawable(new ColorDrawable(Color.RED));
//initialize parse credentials
Button logIn = (Button) findViewById(R.id.bSignIn);
logIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
logIn();
}
});
}
public void logIn(){
getLoginUsername = (EditText) findViewById(R.id.eGetLoginUsername);
getLoginPassword = (EditText) findViewById(R.id.eGetLoginUsername);
loginUsername = getLoginUsername.getText().toString();
loginPassword= getLoginPassword.getText().toString();
ParseUser.logInInBackground(loginUsername, loginPassword, new LogInCallback() {
public void done(ParseUser user, ParseException e) {
if (e == null) {
loginSuccessful();
} else {
Toast.makeText(getApplicationContext(),"Wrong Email/Password Combination", Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
});
}
public void loginSuccessful(){
Intent backToMainIntent = new Intent(LoginActivity.this, MainScreen.class);
startActivity(backToMainIntent);
}
谢谢!
Parse 仪表板上的密码值始终未定义,以阻止您查看用户密码。
我认为它不起作用,因为您的登录代码中存在错误。
getLoginUsername = (EditText) findViewById(R.id.eGetLoginUsername);
getLoginPassword = (EditText) findViewById(R.id.eGetLoginUsername);
这两个 EditText 是相同的,尽管一个用于密码而另一个用于用户名。我猜密码 EditText 的 ID 是错误的。
希望对您有所帮助。