Skip to content

Allow .current to return CustomUser #680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Allow .current to return CustomUser
If we do `Parse.Object.registerSubclass('CustomUser', CustomUser);`, parse still serializes the current user in local storage with `className="_User"`. As such, in subsequent loading of the app, the deserialization process will know nothing of the CustomUser class and `CustomUser.current()` will just return a `Parse.User`. Thus we lose access to all the cool custom methods. Changing the registration to `Parse.Object.registerSubclass('_User', CustomUser)` fixes that.
  • Loading branch information
taivo authored Nov 3, 2019
commit b51b9f7dcb66d9fc9c539d3fc7703ced4b558dd8
6 changes: 3 additions & 3 deletions _includes/js/objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ class CustomUser extends Parse.User {
return 5;
}
}
Parse.Object.registerSubclass('CustomUser', CustomUser);
Parse.Object.registerSubclass('_User', CustomUser);
```

In addition to queries, `logIn` and `signUp` will return the subclass `CustomUser`.
In addition to queries, `logIn`, `signUp`, and `current` will return the subclass `CustomUser`.

```javascript
const customUser = new CustomUser({ foo: 'bar' });
Expand All @@ -117,7 +117,7 @@ customUser.signUp().then((user) => {
});
```

`CustomUser.logIn` and `CustomUser.signUp` will return the subclass `CustomUser` (SDK v2.3.0).
`CustomUser.logIn`, `CustomUser.signUp`, and `Customer.current` will return the subclass `CustomUser` (SDK v2.3.0).

## Saving Objects

Expand Down