Search code examples
meteormeteor-blazemeteor-accounts

Getting currentUser id from server


I'm trying to update a the user "photoPath" field after uploading a file using meteor-uploads. I'm getting this error :

Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.

server/init.js

validateFile: function(file, req) {
    Meteor.users.update( { _id: Meteor.userId() }, {$set: {"profile.photoPath": req.path}});

    return null; 
}

Solution

  • you should use
    this.userId to access user from server side