Search code examples
sessionparse-platformparse-serverback4app

Shouldn't user.destroy() function also destroy session on Parse-Server?


I'm deploying a react native app on back4app using Parse-Server3.9.0. I have a cloud function to delete a user like this:

Parse.Cloud.define("deleteUser", async (request) => {
    if (!request.user) {
        throw 'no user logged in. Impossible to delete account';
    }
    else {
       return await request.user.destroy({useMasterKey:true});
    }
});

After calling it from the client, the currentuser becomes null and the user is correctly deleted from the '_User' table. However, the session remains in the '_Session' table! It looks like a bug to me, but I'm not confident enough with Parse to claim it. I might have missed something. Any idea?

Have a good day,

Julien


Solution

  • It's working as intended-- You asked Parse to delete the User, not the Session. They're two separate objects so they must be deleted separately.

    You can use an afterDelete hook in cloud code to delete any Session or Installation objects associated with the User.