From 9e0c222ba007fc0cf6cdb4dc66620a294909673b Mon Sep 17 00:00:00 2001 From: Tim Medin Date: Tue, 19 Jul 2016 11:27:55 -0500 Subject: [PATCH 1/4] Add onImpersonate callback --- server/lib.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server/lib.js b/server/lib.js index 39effd6..58fc3b4 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 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) + } return { fromUser: currentUser, toUser: params.toUser, token: params.token }; } From ab2273c466046a22b14251e335f9edc9941549fe Mon Sep 17 00:00:00 2001 From: Tim Medin Date: Tue, 19 Jul 2016 11:37:13 -0500 Subject: [PATCH 2/4] Add current and target userIds to onImpersonate callback --- server/lib.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/lib.js b/server/lib.js index 58fc3b4..e8dfbb6 100644 --- a/server/lib.js +++ b/server/lib.js @@ -60,7 +60,7 @@ Meteor.methods({ this.setUserId(params.toUser); if (Impersonate._onImpersonateHook) { - Impersonate._onImpersonateHook(params.toUser) + Impersonate._onImpersonateHook(params.toUser, currentUser); } return { fromUser: currentUser, toUser: params.toUser, token: params.token }; From 3e7acd87624c8c739cd17b7537cd6143b48d17dd Mon Sep 17 00:00:00 2001 From: Tim Medin Date: Tue, 19 Jul 2016 11:50:05 -0500 Subject: [PATCH 3/4] Fix typo in error --- server/lib.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/lib.js b/server/lib.js index e8dfbb6..5ffcd83 100644 --- a/server/lib.js +++ b/server/lib.js @@ -5,7 +5,7 @@ Impersonate = { Impersonate.onImpersonate = function onImpersonate(func) { if (this._onImpersonateHook) { - throw new Error("Can only call onCreateUser once"); + throw new Meteor.Error("Can only call onCreateUser once"); } this._onImpersonateHook = func; }; From 8b1b0c050f388580ccecc5f4a821569f4eb07fec Mon Sep 17 00:00:00 2001 From: Tim Medin Date: Mon, 12 Jun 2017 10:07:58 -0500 Subject: [PATCH 4/4] change package name --- package.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) {