How to use new advanced sessions in Parse with users created in the cloud?

I tested new extended revocable sessions in Parse in an Android app. It works well when logging in or registering through an email password or facebook, but is not suitable for user authentication, for example. Google +.

Now I am registering a user using the cloud code, which also creates a new user during registration. This does not create a new Session object, which means that new extended sessions are not being used and are still using legacy sessions.

I pass the session token back to the client, where it uses the get method with which the user logs in, but these are obsolete sessions.

It seems that the function is not complete, but I would really like to switch to new advanced sessions with my application. Has anyone worked with them yet? Are there workarounds using the REST API or by creating sessions manually and manually processing them? I looked into the JS API, but it says that it is read-only.

Here 's a Blog Entry in Advanced Sessions .

Where should I go next?

+4
source share
1 answer

Yes, I found a solution, but this workaround works for my case, because I do not support logging in with a user / password.

Basically, the solution (cloud code) in the semi-pseudo-code:

  • , user.getSessionToken()
  • , user.become() ,
  • , :
  yourPreviousPromiseInOrderToChainThem.then(function(user) 
    password = new Buffer(24);
    _.times(24, function(i) {
      password.set(i, _.random(0, 255));
    });
    password = password.toString('base64')
    user.setPassword(password);
    return user.save();
  }).then(function(user) {
    return Parse.User.logIn(user.get('username'), password)
  }).then(function(user) {
    var sessionToken = user.getSessionToken();
    // Return the session token to the client as you've been doing with legacy sessions
  })

, , , , , , thist , / ( ), , , , . .

, , , -, , ( Parse.com Parse-Server)

, :)

+1

All Articles