Enable deletion of user preferences
This commit is contained in:
@ -207,10 +207,18 @@ exports.getPreferences = functions.https.onCall((data, context) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// secure function to set a user's filter prefernces in the database
|
// secure function to set a user's filter preferences in the database
|
||||||
exports.postPreferences = functions.https.onCall((data, context) => {
|
exports.postPreferences = functions.https.onCall((data, context) => {
|
||||||
if (!context.auth) return "Error request is not verified"
|
if (!context.auth) return "Error request is not verified"
|
||||||
return admin.firestore().collection('preferences').doc(context.auth.uid).set({data}).then(() => {
|
return admin.firestore().collection('preferences').doc(context.auth.uid).set({data}).then(() => {
|
||||||
return "Successfully saved preferences"
|
return "Successfully saved preferences"
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// secure function to delete a user's filter preferences from the database
|
||||||
|
exports.deletePreferences = functions.https.onCall((data, context) => {
|
||||||
|
if (!context.auth) return "Error request is not verified"
|
||||||
|
return admin.firestore().collection('preferences').doc(context.auth.uid).delete().then(() => {
|
||||||
|
return "Successfully deleted preferences"
|
||||||
|
})
|
||||||
})
|
})
|
@ -18,6 +18,9 @@
|
|||||||
|
|
||||||
<h3>Delete account</h3>
|
<h3>Delete account</h3>
|
||||||
<input @click="deleteUserAccount" type="submit" name="" value="Delete Account">
|
<input @click="deleteUserAccount" type="submit" name="" value="Delete Account">
|
||||||
|
|
||||||
|
<h3>Delete filter preferences data</h3>
|
||||||
|
<button @click="deleteUserPreferences">Delete preferences</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p v-if="missingCredentials">Missing credentials to complete this action</p>
|
<p v-if="missingCredentials">Missing credentials to complete this action</p>
|
||||||
@ -155,6 +158,23 @@ export default {
|
|||||||
this.FirebaseError = error.message
|
this.FirebaseError = error.message
|
||||||
this.displayFirebaseError = true
|
this.displayFirebaseError = true
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
deleteUserPreferences() {
|
||||||
|
const functions = getFunctions(app)
|
||||||
|
let host = window.location.hostname
|
||||||
|
if (host === '127.0.0.1' || host === 'localhost') {
|
||||||
|
connectFunctionsEmulator(functions, host, 5001);
|
||||||
|
}
|
||||||
|
const deletePreferencesData = httpsCallable(functions, 'deletePreferences')
|
||||||
|
deletePreferencesData().then(() => {
|
||||||
|
this.FirebaseSuccessMsg = "Successfully deleted filter preferences"
|
||||||
|
this.displayFirebaseSuccessMsg = true
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
this.FirebaseError = error.message
|
||||||
|
this.displayFirebaseError = true
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,6 @@ export default {
|
|||||||
this.showNotYetRunning = response.data.data["showNotYetRunning"]
|
this.showNotYetRunning = response.data.data["showNotYetRunning"]
|
||||||
|
|
||||||
// update the map with the user's preferences
|
// update the map with the user's preferences
|
||||||
console.log("got preferences")
|
|
||||||
this.decideShowStations()
|
this.decideShowStations()
|
||||||
this.decideShowTrains()
|
this.decideShowTrains()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user