0
Good afternoon.
I would like to know how to make the data saved by a user be only seen by him once he has logged in.
I am using Vue.js2 and Firebase. I followed this tutorial:
https://blog.logrocket.com/vue-firebase-authentication/
Everything works perfectly: new user registration, login, logout, save data. However, when a user accesses your account and clicks on the button to view your data, all data of all users appears to them. Below, follow the codes (only referring to Firebase):
Registering:
methods: {
submit() {
firebase.auth().createUserWithEmailAndPassword(this.form.email, this.form.password).then(data => {
data.user.updateProfile({
displayName: this.form.name,
})
.then(() => {});
alert('Cadastro efetuado com sucesso!')
this.form.name = ''
this.form.email = ''
this.form.password = ''
})
.catch((err) => {
this.error = err.message;
});
},
Login
methods: {
submit() {
firebase
.auth()
.signInWithEmailAndPassword(this.form.email, this.form.password)
.then(() => {
this.$router.replace({ name: "dashboard" });
})
.catch((err) => {
this.error = err.message;
});
},
},
Insert Data
methods: {
salvar() {
this.$http.post("usuarios.json", this.usuario).child(uid).set({
name: this.form.name
});
alert('Escrito adicionado com sucesso!')
},
},
And finally load the data
methods: {
carregar(id) {
this.$http.get("usuarios.json").then((res) => {
this.usuarios = res.data;
});
this.id = id
this.usuario = { ...this.usuarios[id] }
}
}
I hope that has been made clear. Thank you very much in advance.