Skip to content
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

Issue in Assigning UserExtension from Request User #5003

Closed
skparticles opened this issue Aug 25, 2018 · 2 comments
Closed

Issue in Assigning UserExtension from Request User #5003

skparticles opened this issue Aug 25, 2018 · 2 comments

Comments

@skparticles
Copy link

UserExtension methods is not accessible.

Parse.Cloud.define("cloudFunctionName", function (req, res) {
let userExtension = req.user;
userExtension.setDisplayName("newDisplayName"); // TypeError: currentUser.setDisplayName is not a function
userExtension.save();
});
class UserExtension extends Parse.Object {
    constructor(){
        super('_User');
    }
getDisplayName(){
        this.get("displayName");
    }
    setDisplayName(value){
        this.set('displayName',value);
    }
}

Parse.Object.registerSubclass('UserExtension', UserExtension);
module.exports = UserExtension;
@flovilmart
Copy link
Contributor

Well this makes sense as you're registeing the subclass for 'UserExtension' className. and req.user will always and ever be a '_User'.

you should use:

class UserExtension extends Parse.User {
    getDisplayName(){
        this.get("displayName");
    }
    setDisplayName(value){
        this.set('displayName',value);
    }
}
Parse.Object.registerSubclass('_User', UserExtension);

i just tested and it works are expected.

@skparticles
Copy link
Author

@flovilmart Wow, you saved my hours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants