Parziphal / parse

Parse with an Eloquent-like interface for Laravel
MIT License
17 stars 13 forks source link

Invalid session token errors when adding users #25

Closed nafplann closed 5 years ago

nafplann commented 5 years ago

Hi again. I have admin panel where I can add, edit, remove users. The problem is after I delete some user records then i try to add a new one it throws invalid session token errors.

I think its because this library doesn't have the option to useMasterKey on userModel signUp method. Do you have any suggestions?

Parziphal commented 5 years ago

Hi. If that error is from Parse, that would mean that the session token you are using is lost in the way somehow? I don't know why would that happen. If you could post the exception message and backtrace maybe we could know the reason.

About useMasterKey in the signUp method, we can't signUp users using master key, that isn't supported by the Parse PHP SDK. Here's Parse's signUp method.

nafplann commented 5 years ago

after deleting a user, when I check Parse\ParseUser::getCurrentUser() my session is replaced by the deleted user session

nafplann commented 5 years ago

I think I found it. When adding users it seems we use signUp method instead of save method right? thats when the sessiontoken gets overwritten

Parziphal commented 5 years ago

Ooh, that makes sense. Checking the signUp() method linked above, we can see that it calls handleSaveResult(true), which makes the new user the current user because of that true value. The signUp() method only makes some checks before calling parent::save(), so creating a new user takes nothing more than a save() call. Maybe you could do that: instead of creating users with signUp(), call save().

nafplann commented 5 years ago

Thanks for the help. I ended up create a new model extending ObjectModel instead of UserModel to make it work the way I need.

I'll close this.