Skip to content

Instantly share code, notes, and snippets.

@KeKs0r
Created May 7, 2019 12:48
Show Gist options
  • Save KeKs0r/e49dc45bfed892285d64049ee20e6de2 to your computer and use it in GitHub Desktop.
Save KeKs0r/e49dc45bfed892285d64049ee20e6de2 to your computer and use it in GitHub Desktop.
const functions = require("firebase-functions");
const got = require("got");
const _ = require("lodash");
const notifyNewSignup = functions
.runWith({ memory: "128MB" })
.region("europe-west1")
.auth.user()
.onCreate(user => {
const email = user.email;
const displayName = user.displayName;
const provider = _.get(user, "providerData.0.providerId");
const url = functions.config().slack.url;
if (!url) {
console.warn("You need to define the slack webhook URL");
}
const text = `New user signup: ${displayName} (${email}) via ${provider}`;
return got.post(url, {
body: JSON.stringify({
text,
username: "User Registration",
icon_emoji: ":sparkles:"
})
});
});
module.exports = notifyNewSignup;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment