Skip to content

Instantly share code, notes, and snippets.

Last active May 3, 2017 14:50
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save eh3rrera/00ee1aeb462777736f4e441694662c5d to your computer and use it in GitHub Desktop.
Auth0 rule to publish a signup/login event to Pusher
function (user, context, callback) {
var Pusher = require('pusher@1.2.1');
var pusher = new Pusher({
encrypted: true
user.app_metadata = user.app_metadata || {};
var channel = 'auth0';
var event = 'user-signedUp';
var userClonedObj = JSON.parse(JSON.stringify(user)); = context.request.geoip.country_name;
if (user.app_metadata.signedUp) {
event = 'user-loggedIn';
} else {
user.app_metadata.signedUp = true;
auth0.users.updateAppMetadata(user.user_id, user.app_metadata);
pusher.trigger(channel, event, userClonedObj);
callback(null, user, context);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment