Skip to content

Instantly share code, notes, and snippets.

@parthibanloganathan
Last active June 5, 2020 02:09
Show Gist options
  • Save parthibanloganathan/bf1cece1706a05db0daef66ee272a68b to your computer and use it in GitHub Desktop.
Save parthibanloganathan/bf1cece1706a05db0daef66ee272a68b to your computer and use it in GitHub Desktop.
helpelf_getuser
import * as admin from "firebase-admin";
import User from "../models/user";
import express from "express";
var router = express.Router();
...
router.post(
"/getuser",
[],
asyncHandler(async (request, response, next) => {
let firebaseUserId;
try {
const decodedToken = await admin.auth().verifyIdToken(request.body.idToken);
firebaseUserId = decodedToken.uid;
} catch (error) {
return response.status(400).send(error);
}
let user = await getUserFromFirebaseId(firebaseUserId); // this is now a spoofed user if the requesting user was an admin with a spoofUserId set
if (!user) {
response.status(400).send("Invalid user");
}
return response.status(200).send({});
})
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment