Add and store user preferences
This commit is contained in:
@ -199,13 +199,18 @@ exports.postLiveTrainData = functions.https.onRequest((request, response) => {
|
||||
})
|
||||
})
|
||||
|
||||
exports.securefunction = functions.https.onCall((data, context) => {
|
||||
if (typeof context.auth === undefined) {
|
||||
// user not logged in
|
||||
return "User is not logged in"
|
||||
}
|
||||
else {
|
||||
// user logged in
|
||||
return "User is logged in"
|
||||
}
|
||||
})
|
||||
// secure function to fetch a user's filter preferences from the database
|
||||
exports.getPreferences = functions.https.onCall((data, context) => {
|
||||
if (!context.auth) return "Error request is not verified"
|
||||
return admin.firestore().collection('preferences').doc(context.auth.uid).get().then((preferences) => {
|
||||
return preferences.data()
|
||||
})
|
||||
})
|
||||
|
||||
// secure function to set a user's filter prefernces in the database
|
||||
exports.postPreferences = functions.https.onCall((data, context) => {
|
||||
if (!context.auth) return "Error request is not verified"
|
||||
return admin.firestore().collection('preferences').doc(context.auth.uid).set({data}).then(() => {
|
||||
return "Successfully saved preferences"
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user