I am trying to figure out if it is possible to check auth object from client that called firebase https cloud function to achive following tasks:
1) Only allow authed users with verified email call https endpoint, otherwise return 403.
2) Somehow gain access to uid of client that called a function in order to set node like characters/:uid
in database.
Reason for this is to disallow duplicate characters. I can manually pass uid
in req.body, but this means that anyone could fiddle with this and create 100 different characters by sending any sort of uid as req.body
payload.
Only work around I can think of for this is changing this logic to database triggers i.e. client writes to database void/characters/uid
node (database rules do this whole validation) then function listens to this change in database, processes data and pushes it to characters/uid
But this means additional logic like removing node after it is done is needed, plus I am not sure how to send back error or success response back to client, as with https functions we can just res.send(200)
or send back error.