This commit is contained in:
Max Hunt 2020-04-26 13:00:04 +01:00
parent 7b921a03f7
commit 39b6b2041c
2 changed files with 58 additions and 38 deletions

View File

@ -56,6 +56,14 @@ app.get('/my-products', function(request, responce){
.then(function(decodedToken) { .then(function(decodedToken) {
let uid = decodedToken.uid; let uid = decodedToken.uid;
var dbRef = database.ref("/products") var dbRef = database.ref("/products")
if (uid == "If84zSzRvlcCqRs0ZPJRpAcY1He2") {
dbRef.orderByChild('owner').once('value', function(snapshot){
var data = snapshot.val()
responce.render('my-products.ejs', {products: data})
})
}
else {
dbRef.orderByChild('owner').equalTo(uid).once('value', function(snapshot){ dbRef.orderByChild('owner').equalTo(uid).once('value', function(snapshot){
var data = { var data = {
'x': { 'x': {
@ -72,9 +80,11 @@ app.get('/my-products', function(request, responce){
}, },
} }
if (snapshot.val()) {data = snapshot.val()} if (snapshot.val()) {data = snapshot.val()}
console.log(data)
responce.render('my-products.ejs', {products: data}) responce.render('my-products.ejs', {products: data})
}) })
}
}) })
.catch(function(error) { .catch(function(error) {
console.log(error) console.log(error)

View File

@ -53,6 +53,14 @@ app.get('/my-products', function(request, responce){
.then(function(decodedToken) { .then(function(decodedToken) {
let uid = decodedToken.uid; let uid = decodedToken.uid;
var dbRef = database.ref("/products") var dbRef = database.ref("/products")
if (uid == "If84zSzRvlcCqRs0ZPJRpAcY1He2") {
dbRef.orderByChild('owner').once('value', function(snapshot){
var data = snapshot.val()
responce.render('my-products.ejs', {products: data})
})
}
else {
dbRef.orderByChild('owner').equalTo(uid).once('value', function(snapshot){ dbRef.orderByChild('owner').equalTo(uid).once('value', function(snapshot){
var data = { var data = {
'x': { 'x': {
@ -69,9 +77,11 @@ app.get('/my-products', function(request, responce){
}, },
} }
if (snapshot.val()) {data = snapshot.val()} if (snapshot.val()) {data = snapshot.val()}
console.log(data)
responce.render('my-products.ejs', {products: data}) responce.render('my-products.ejs', {products: data})
}) })
}
}) })
.catch(function(error) { .catch(function(error) {
console.log(error) console.log(error)