diff --git a/functions/index.js b/functions/index.js index 0d54a13..69e713d 100644 --- a/functions/index.js +++ b/functions/index.js @@ -117,6 +117,32 @@ app.get('/my-product', function(request, responce){ } }) +app.get('/edit-item', function(request, responce){ + if (request.query.uToken && request.query.productid) { + admin.auth().verifyIdToken(request.query.uToken) + .then(function(decodedToken) { + let uid = decodedToken.uid; + var dbRef = database.ref("/products/"+request.query.productid) + dbRef.once('value', function(snapshot){ + data = snapshot.val() + if (data.owner == uid) { + responce.render('edit-item.ejs', {item:data, key:request.query.productid}) + } + else { + responce.send('

Unauthorized user

Home') + } + }) + }) + .catch(function(error) { + console.log(error) + responce.send("

Bad Auth Token

Home") + }); + } + else { + responce.send("

No Auth Token Provided

Home") + } +}) + app.get('/product', function(request, responce){ if (request.query.productid) { var dbRef = database.ref("/products/"+request.query.productid) diff --git a/functions/views/edit-item.ejs b/functions/views/edit-item.ejs new file mode 100644 index 0000000..b3c2654 --- /dev/null +++ b/functions/views/edit-item.ejs @@ -0,0 +1,103 @@ + + + + + + + GG Prototype + + + + + + + + + + + + + + + +
+
+ + +
+ + +
+

Edit product

+
+ +
+
+ +
+ + +
+ +
+ +
+ + + + + + + + +
+
+ +
+ + + + + + \ No newline at end of file diff --git a/functions/views/home.ejs b/functions/views/home.ejs index 1895646..9af1201 100644 --- a/functions/views/home.ejs +++ b/functions/views/home.ejs @@ -24,7 +24,7 @@