Last active
June 5, 2020 02:09
-
-
Save parthibanloganathan/bf1cece1706a05db0daef66ee272a68b to your computer and use it in GitHub Desktop.
helpelf_getuser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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