Take Some Server actions on Client logout?[SOLVED]


#1
 logout(callback) {
    var self = this;
    self._loggingOut.set(true);
    self.connection.apply('logout', [], {
      wait: true
    }, function (error, result) {
      self._loggingOut.set(false);
      if (error) {
        callback && callback(error);
      } else {
        self.makeClientLoggedOut();
        callback && callback();
      }
    });
  }

That is the code for logging out on the client. I see it calls some ‘logout’ method on the server

How do I ‘get the method’ i.e do something that method is called, without creating a new logout Method or custom logout method.

Thoughts?


#2
Meteor.default_server.method_handlers['logout'] = function () {
    let accounts = Accounts
    var token = accounts._getLoginToken(this.connection.id);
    accounts._setLoginToken(this.userId, this.connection, null);
    if (token && this.userId) accounts.destroyToken(this.userId, token);
    accounts._successfulLogout(this.connection, this.userId);
    this.setUserId(null);

/*
Can I do my own things here ??
*/

}

This is the server code to logging out . I am going to update it to serve my other purposes. . Those this 'Make sense ’


#3