Edit browser information when logged in as another user in android

I am using parse.com in my android app. When I visit another user profile, I can follow that user, but when I follow it, the value in the next column of the currently logged in user object is updated, but at the same time, the time when the custom value I followed is not updated It gives:

06-27 05:11:44.521: E/AndroidRuntime(2459): java.lang.IllegalArgumentException: Cannot save a ParseUser that is not authenticated.

      

Here is my Android code package com.example.wavie.parseQueryRunner;

import android.content.Context;

import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.ParseUser;

public class FollowUserClass {
    private String id;
    private Context context;

    public FollowUserClass(String id, Context context) {
        this.id = id;
        this.context = context;

    }

    public void follow() {
        ParseUser currentUser=ParseUser.getCurrentUser();
        currentUser.addUnique("following", id);
        try {
            currentUser.save();
            ParseQuery<ParseObject> query=new ParseQuery<ParseObject>("_User");
            query.getInBackground(id, new GetCallback<ParseObject>() {

                @Override
                public void done(ParseObject object, ParseException e) {
                    // TODO Auto-generated method stub
                    if(e==null && object!=null){
                        object.addUnique("followers", ParseUser.getCurrentUser().getObjectId());
                        try {
                            object.save();
                        } catch (ParseException e1) {
                            // TODO Auto-generated catch block
                            e1.printStackTrace();
                        }
                    }

                }
            });
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }



    }
}

      

in the constructor of the code section takes the id of the user object I want to follow First it updates the currently logged in user, adds the accepted id to the next field (array).

then I tried to do the update in another user object by adding the line

    object.addUnique("followers", 
ParseUser.getCurrentUser().getObjectId());

      

but when i save it the parse user needs to be authenticated before ssaving

+3


source to share


2 answers


I found the answer the next day when I asked this question. This time, the only way to do it is to deploy cloud code. in fact the user I wanted to update was another user, so it is not possible to update someone else's information in the database .parse provides a solution to this in android (possibly in js) by deploying cloud code to the server. parse gives a command line tool to do this for linux run the following command to install curl -s https://www.parse.com/downloads/cloud_code/installer.sh | sudo / bin / bash



After successful installation, a folder named parse / etc / will be created in the home. now enter command parse $ configure accountkey -d in terminal, it will ask for your credentials. now enter the parse command in the terminal to select one of your existing applications. now you open main.js file in home / etc / parse edit. switch to terminal deployment code using $ parse deploy. now you can use the cloud code that was deployed

+2


source


This error mentions a problem. The user is not authenticated to perform the operation. This happens when the user updating the string in the parsing is not the one who created the corresponding string.



So you should probably grant write access to the user who is updating the records.

0


source







All Articles