message: ImpersonatorAuth callable
diff: @@ -3,7 +3,7 @@ import * as _ from "lodash";
  import * as admin from "firebase-admin";
  import { sendEmail } from "./utils/email";
  import { hasAnyRole } from "./utils/auth";
  -
  +import { auth } from "./config";
  const serverTimestamp = admin.firestore.FieldValue.serverTimestamp;
  const sendEmailTemplateCallable = async (
  @@ -45,3 +45,32 @@ const sendEmailTemplateCallable = async (
  };
  export const SendEmail = functions.https.onCall(sendEmailTemplateCallable);
  +
  +// Impersonator Auth callable takes email and returns JWT of user on firebaseAuth
  +// requires a user admin role
  +
  +export const ImpersonatorAuth = functions.https.onCall(
  + async (data, context) => {
  + try {
  + if (hasAnyRole(["ADMIN"], context)) {
  + const user = await auth.getUserByEmail(data.email);
  + const jwt = await auth.createCustomToken(user.uid);
  + return {
  + success: true,
  + jwt,
  + message: "successfully generated token",
  + };
  + } else {
  + return {
  + success: false,
  + message: "needs admin role",
  + };
  + }
  + } catch (error) {
  + return {
  + success: false,
  + message: JSON.stringify(error),
  + };
  + }
  + }
  +);
  