class CustomUser extends ParseUser {
customMethod() {
return 'a';
}
}
ParseObject.registerSubclass(ParseUser.className, CustomUser);
CustomUser.logIn('username', 'password').then((u) => {
expect(u instanceof CustomUser).toBe(true);
expect(u.customMethod()).toBe('a');
});
Failing test case:
https://github.com/drinklynk/Parse-SDK-JS/commit/0a9fa9cfeee1dd9d2e47a356849ee67ae161e97a
Interesting. Seems like rather than instantiating a new ParseUser directly, we want to use the className approach and create a new ParseObject('_User').
This might get a little tricky with the user class rewrite flag, but I'll look into this.
Same problem seems to exist with User.become
Any workaround for this issue?
This hasn鈥檛 been addressed yet, but further investigation would be appreciated
I found a way to do it
let user = new MyCustomUserClass;
user.username = 'johndoe';
user.password = 'secret';
user.logIn(null).then(obj => {
/// obj is an instance of MyCustomUserClass
Thanks fmendoza, this workaroud is really helpfull.
This workaround seems to no longer work with parse server v3 as we get username/email is required, @fmendoza can you confirm?
Still working on my end with Parse Server v3 and Parse SDK JS 2.1
Most helpful comment
I found a way to do it