diff --git a/package.js b/package.js index 9c2ce61..66419c1 100644 --- a/package.js +++ b/package.js @@ -1,8 +1,8 @@ Package.describe({ - name: "gwendall:impersonate", + name: "nidem-impersonate", summary: "Impersonate users in Meteor", version: "0.2.2", - git: "https://github.com/gwendall/meteor-impersonate.git", + git: "https://github.com/nidem/meteor-impersonate.git", }); Package.onUse(function (api, where) { diff --git a/server/lib.js b/server/lib.js index 39effd6..5ffcd83 100644 --- a/server/lib.js +++ b/server/lib.js @@ -3,6 +3,13 @@ Impersonate = { adminGroups:[], // { role: "admin", group: "organization" } }; +Impersonate.onImpersonate = function onImpersonate(func) { + if (this._onImpersonateHook) { + throw new Meteor.Error("Can only call onCreateUser once"); + } + this._onImpersonateHook = func; +}; + Meteor.methods({ impersonate: function(params) { @@ -52,6 +59,9 @@ Meteor.methods({ } this.setUserId(params.toUser); + if (Impersonate._onImpersonateHook) { + Impersonate._onImpersonateHook(params.toUser, currentUser); + } return { fromUser: currentUser, toUser: params.toUser, token: params.token }; }