I am creating a platform for buyers and sellers. I want to differentiate between a buyer's account and a seller account so I tagged each account as user or seller. The firebase database structure is like this,
I want to do a check if the current user is a "user" or "seller" using this function
function checkaccttype(){
firebase.auth().onAuthStateChanged((user) => {
if (user) {
var userId = firebase.auth().currentUser.uid;
var userref = rootref.ref('/Users/' + userId).once('value', function(snapshot) {
console.log(" let's check if this guy is a seller")
if (snapshot.val().accttype = "seller") {
// window.location = "../html/SellerDB.html"
remove("seller_btn");
console.log("this guy is a seller")
} else {
console.log(" common this guy is no SELLER, is a user")
}
})
} else {
console.log("user is not logged in");
}
})
}
but surprisingly, event if the accttype = "user", it still recognize it as a seller by printing this "this guy is a seller". How can I properly differentiate the two different accounts in firebase?
Aucun commentaire:
Enregistrer un commentaire