Added code which does something, not my dislike of firebase
This commit is contained in:
@@ -1,9 +1,46 @@
|
|||||||
const functions = require("firebase-functions");
|
const functions = require("firebase-functions");
|
||||||
|
const admin = require("firebase-admin");
|
||||||
|
admin.initializeApp();
|
||||||
|
const db = admin.firestore();
|
||||||
// // Create and Deploy Your First Cloud Functions
|
// // Create and Deploy Your First Cloud Functions
|
||||||
// // https://firebase.google.com/docs/functions/write-firebase-functions
|
// // https://firebase.google.com/docs/functions/write-firebase-functions
|
||||||
//
|
//
|
||||||
// exports.helloWorld = functions.https.onRequest((request, response) => {
|
exports.messageTester = functions.https.onRequest((request, response) => {
|
||||||
// functions.logger.info("Hello logs!", {structuredData: true});
|
functions.logger.info("Message was requested", {structuredData: true});
|
||||||
// response.send("Hello from Firebase!");
|
response.send("Sending message");
|
||||||
// });
|
});
|
||||||
|
|
||||||
|
|
||||||
|
exports.userCreated = functions.auth.user().onCreate((user) => {
|
||||||
|
return admin.auth().setCustomUserClaims(user.uid, {
|
||||||
|
admin: false,
|
||||||
|
role: undefined,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
exports.roleDefined = functions.https.onCall((data, context) => {
|
||||||
|
if (data.role == "firstAider") {
|
||||||
|
admin.auth().setCustomUserClaims(user.uid, {
|
||||||
|
role: "firstAider",
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return db.collection("users").doc(user.uid).set({
|
||||||
|
role: "patient",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
exports.firstAiderCreated = functions.firestore.document("first-aiders/{userId}/")
|
||||||
|
.onCreate(async (snap, context) => {
|
||||||
|
admin.auth().setCustomUserClaims(snap.id, {
|
||||||
|
role: "firstAider",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
exports.firstAiderCreated = functions.firestore.document("patients/{userId}/")
|
||||||
|
.onCreate(async (snap, context) => {
|
||||||
|
admin.auth().setCustomUserClaims(snap.id, {
|
||||||
|
role: "patient",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
//patient firstAider
|
||||||
Reference in New Issue
Block a user