0

I'm trying to create new users with random passwords through cloudCode, but I always get an error. The error's body is the password I set.

Here's my code:

Parse.Cloud.define('account', function(request, response) {
  Parse.Cloud.useMasterKey();
  var randomString = Math.random().toString(36).slice(-8);
  var user = new Parse.User();
  user.setUsername(request.email);
  user.setPassword(randomString);
  user.signUp(null, {
    success: function(newUser) {
      response.success('Hooray');
    },
    error: function(error) {
      response.error(error);
    }
  });
});

What I get as an error is: b.Error {code: 141, message: "{"password":"tnm3rf6r"}"}

Can anyone help ?

I've already tried placing useMasterKey() outside of the function, inside, right before the signUp, etc.

1 Answer 1

1

Ok, I found my mistake.

You have to call request.params.parameterName and not just request.parameterName.

Silly Mistake.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.