1

Trying something that should be simple, creating a new User account from an Admin dashboard using Parse server on Back4app.

Every time I try the new user is created but I am unable to switch back to the original user...

var sessionToken = Parse.User.current().getSessionToken();

                        Parse.User.signUp(email, email).then(function(newUser) {
                            Parse.User.logOut();
                            Parse.User.become(sessionToken);
                        });

Thanks

stuart
  • 425
  • 6
  • 19

2 Answers2

0

logOut and become are asynchronous functions, if I'm not mistaken. So you're trying to become another user when you haven't logged out of the original user, which I don't think works.

Jake T.
  • 4,308
  • 2
  • 20
  • 48
0

All of these parse user functions you are using returns a promise, I suspect there is some asynchronous magic going on - try chaining them together like this and see if that fixes the issue.

Parse.User.signUp(email, email)
.then(function(newUser) 
{ return Parse.User.logOut()}
.then(function() { return Parse.User.become(sessionToken)}

For reference:

http://parseplatform.org/Parse-SDK-JS/api/classes/Parse.User.html#methods_logOut

Neels
  • 2,547
  • 6
  • 33
  • 40
Brian C
  • 101
  • 1
  • 1
  • 3
  • thanks for the answer, but it does not seem to help, I suppose I need to put the code in Cloud code and call a function. – stuart Sep 07 '17 at 08:45