Search code examples
meteorpackageaccount

Meteor.userId() null inside a package


I am creating a meteor package. This package has use ofaccount-base in package.json.

I have created a method on server side like this:

Meteor.methods({
    hide: function(notification_id){
        kahonNotification.hide(notification_id,Meteor.userId())
    }    
});

The problem is that Meteor.userId() is null all time.

here is the configuration package.json file:

Package.onUse(function(api) {
  api.versionsFrom('1.0.5');
  api.use(['standard-app-packages'], ['client','server']);
  api.use('accounts-base', 'server');

  // Allows the user of this package to choose their own Bootstrap
  // implementation.
  api.use(['twbs:[email protected]', 'nemo64:[email protected]_1'], 'client', {weak: true});

  api.addFiles(['client/notifications.html','client/notifications.js'],'client');
  api.addFiles(['server/main.js','server/publications.js'],'server');
  api.addFiles('shared/collections.js',['server','client'])

  api.imply(['templating'], 'client');
  api.export('kahonNotification')

});

Package.onTest(function(api) {
  api.use('tinytest');
  api.use('kahon:notificationsefficient');
  api.addFiles('notificationsefficient-tests.js');
});

Solution

  • I was not logged in the web page. It is the solution.