Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allowClientClassCreation is not working #4527

Closed
Nisthar opened this issue Jan 29, 2018 · 3 comments
Closed

allowClientClassCreation is not working #4527

Nisthar opened this issue Jan 29, 2018 · 3 comments

Comments

@Nisthar
Copy link

Nisthar commented Jan 29, 2018

I used https://github.com/parse-community/parse-server-example to host my parse server on heroku.

I have edited my index.js file:

var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || 'myAppId',
  masterKey: process.env.MASTER_KEY || '', //Add your master key here. Keep it secret!
  serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse',  // Don't forget to change to https if needed
  liveQuery: {
    classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
  },
  enableAnonymousUsers: process.env.ANON_USERS || false,
  allowClientClassCreation: process.env.CLIENT_CLASS_CREATION || false
});

I added CLIENT_CLASS_CREATION and set it to false.

My parse client is android. I am using this code:

 Parse.enableLocalDatastore(this);
        Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE);
        Parse.initialize(new Parse.Configuration.Builder(this)
                .applicationId(getString(R.string.parse_app_id))
                .server(getString(R.string.parse_server_url))
                .build()
        );
 FacebookSdk.sdkInitialize(getApplicationContext());
        ParseFacebookUtils.initialize(this);

 ParseACL defaultACL = new ParseACL();
        defaultACL.setPublicReadAccess(true);
        defaultACL.setPublicWriteAccess(false);
        ParseACL.setDefaultACL(defaultACL, true);

        ParseObject object = new ParseObject("app3");
        object.put("user","TestUser");

        object.saveEventually(new SaveCallback() {
            @Override
            public void done(ParseException e) {
                if (e == null) {
                    Log.i("Parse","SUCCESS");
                } else {
                    Log.i("Parse","FAILED");
                    e.printStackTrace();
                }
            }
        });

The query should fail. But its giving me SUCESS

What am i missing here?

@Nisthar Nisthar changed the title allowClientClass is not working allowClientClassCreation is not working Jan 29, 2018
@tolgaatam
Copy link

hey,

i'm not sure if the booleanParser only parses strings directly coming from the environment variables, so my suggestion might not be working but you might want to try.

i assume the problem happens because you are passing the string 'false' to the main config and it is not being processed as the boolean false. rather than trying to set an environment variable yourself, use the envorinment variable:

PARSE_SERVER_ALLOW_CLIENT_CLASS_CREATION

this is a predefined environment variable and setting this to false should do the trick for you and you can clear your allowClientClassCreation from the config.
if this does not work, then parse server guys might be talking about some serious problems

you can find more default environment variables at src/Options/Definitions.js in parse-server code :)

@stale
Copy link

stale bot commented Sep 18, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Sep 18, 2018
@stale stale bot closed this as completed Sep 25, 2018
@mryalamanchi
Copy link

mryalamanchi commented Jan 4, 2019

@Nisthar the environment variables are of type String, when being imported in nodejs using the process.env.ENV_VAR. So you need to convert the respective ENV_VAR from string to the Boolean type, since both enableAnonymousUsers and allowClientClassCreation accept Boolean values only. A non-empty string gives it a true value no matter whatever the content is.

You can use "yn" package which converts the respective String, containing Boolean type values, to Boolean type. So your code should look something like this :

const yn = require("yn");
.
.
.
enableAnonymousUsers: yn(process.env.ANON_USERS) || false,
allowClientClassCreation: yn(process.env.CLIENT_CLASS_CREATION) || false

This should solve the problem.

After adding this, committing and pushing the code, Heroku's nodejs buildpack might give you errors saying "yn package was not found", then all you need to do is remove the node_modules from your local repository, do fresh npm install and then set the Heroku config NODE_MODULES_CACHE to false

$ heroku config:set NODE_MODULES_CACHE=false

If still it gives you any other errors, then kindly continue to post the error here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants