ParseObject.save () throws IllegalArgumentException (Cannot save user who is not authenticated) WHY?
I have a table in db, we can name it "A" with just two columns:
user (Pointer _User)
b (Pointer "B") (where "B" is another table in my db)
code:
a.put("b", b);
a.put("user", ParseUser.getCurrentUser());
a.save(); //I manage my threading
on a.save () IllegalArgumentException in header please can someone explain to me why? There is a column in table "B" pointing to another _User, I hope the problem doesn't depend on that !!!
this is the logcat output:
source to share
From the official docs
Security for custom objects
The ParseUser class is protected by default. The data stored in ParseUser
can only be modified by this user. By default, data can be read by any client. Thus, some objects are ParseUser
authenticated and can be modified, while others are read-only.
In particular, you cannot call any methods such as save or delete, unless ParseUser
it was obtained using an authenticated method such as logIn
or signUp
. This ensures that only the user can change their own data.
Below is this security policy:
ParseUser user = ParseUser.logIn("my_username", "my_password");
user.setUsername("my_new_username"); // attempt to change username
user.saveInBackground(); // This succeeds, since the user was authenticated on the device
// Get the user from a non-authenticated manner
ParseQuery<ParseUser> query = ParseUser.getQuery();
query.getInBackground(user.getObjectId(), new GetCallback<ParseUser>() {
public void done(ParseUser object, ParseException e) {
object.setUsername("another_username");
// This will throw an exception, since the ParseUser is not authenticated
object.saveInBackground();
}
});
ParseUser
received from getCurrentUser()
will always be authenticated.
If you need to authenticate ParseUser
, you can call the method isAuthenticated()
. You don't need to check isAuthenticated()
for ParseUser
objects obtained with an authenticated method.
source to share