Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- exports.auth = functions.https.onRequest((req, res) => {
- const email = req.body.email;
- const passcode = req.body.passcode;
- admin.auth().getUserByEmail(email)
- .then(user => {
- return user.uid
- })
- .then(uid => {
- return admin.firestore().collection('contracts').where('uid', '==', uid).get()
- .then(data => {
- const contract = {uid: uid}
- data.forEach(doc => {
- if (doc.data().passCode == passcode) contract.id = doc.data().id
- })
- return contract
- })
- })
- .then(data => {
- return admin.auth().createCustomToken(data.uid)
- .then(token => {
- res.send({token: token, contractId: data.id})
- })
- })
- .catch(err => res.send(err.message))
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement