I'm working on implementing a function in my Vue.js Firebase application that allows users to be deleted by UID. The app is designed to allow user registration through email and password authentication in Firebase. Once a user is logged in, they should have the ability to click a button to delete their email, password, and user data from Firebase. Currently, my delete function looks like this:
async deleteProfile () {
let ref = db.collection('users')
let user = await ref.where('user_id', '==', firebase.auth().currentUser.uid).get()
user.delete()
}
However, I keep running into the issue of "user.delete() is not a function." How can I modify this function to successfully delete the user from authentication and the database? Thank you!
UPDATED FUNCTION
async deleteProfile () {
let ref = db.collection('users')
let user = await ref.where('user_id', '==', firebase.auth().currentUser.uid).get()
await user.ref.delete()
await firebase.auth().currentUser.delete()
}