diff --git a/consumerWebsite/functions/api.js b/consumerWebsite/functions/api.js index 4ba3737..bbdbbe0 100644 --- a/consumerWebsite/functions/api.js +++ b/consumerWebsite/functions/api.js @@ -13,7 +13,7 @@ const { generateUUID } = require("./generateUUID.js"); //can be used for api key or token. Both are the same logic async function addAPIKey(userId, permission) { let hashtoken = await generateUUID(); - let apikey = await hashAPIKey(hashtoken); + let apikey = await hash(hashtoken); let token = await apikeyModel.create({ userid: userId, diff --git a/consumerWebsite/functions/bcrypt.js b/consumerWebsite/functions/bcrypt.js index f5fa6ae..8a6bc7a 100644 --- a/consumerWebsite/functions/bcrypt.js +++ b/consumerWebsite/functions/bcrypt.js @@ -2,26 +2,6 @@ const bcrypt = require('bcrypt'); const saltRounds = 10; //https://github.com/kelektiv/node.bcrypt.js#readme - -/* -// Load hash from your password DB. -bcrypt.compare(myPlaintextPassword, hash, function(err, result) { - // result == true -}); -bcrypt.compare(someOtherPlaintextPassword, hash, function(err, result) { - // result == false -}); -*/ - - -/* -//hash with salt -bcrypt.hash(myPlaintextPassword, saltRounds, function(err, hash) { - // Store hash in your password DB. -}); - -*/ - //hash for pass or token lol doesnt matter async function hash(password) { return await bcrypt.hash(password, saltRounds); diff --git a/consumerWebsite/functions/location.js b/consumerWebsite/functions/location.js index e13c659..97fc0c4 100644 --- a/consumerWebsite/functions/location.js +++ b/consumerWebsite/functions/location.js @@ -6,6 +6,7 @@ async function getLocation() { } async function addLocation(name, added_by, description) { + console.log(name, added_by, description); const location = await locationModel.create({ name: name, added_by: added_by, diff --git a/consumerWebsite/functions/user.js b/consumerWebsite/functions/user.js index 44582e1..9cfb6e0 100644 --- a/consumerWebsite/functions/user.js +++ b/consumerWebsite/functions/user.js @@ -20,6 +20,8 @@ async function getUserID(userid) { return userRes; } +//register +//api/v0/auth/register async function addUser(user) { //hash password let hashed = await hash(user.password); @@ -40,21 +42,6 @@ async function addUser(user) { } } -//getuser -//api/v0/user/me -async function getUserID(userid) { - //console.log(userid); - //console.log(userid.id); - let userRes = await userModel.findByPk(userid.id, { - attributes: { - exclude: ["password"], - }, - }); - - if (!userRes) return false; - return userRes; -} - //api/v0/auth/register /* Registering new user 1) req.body is taken from html form or wtv diff --git a/consumerWebsite/routes/location.js b/consumerWebsite/routes/location.js index cc7ce2b..6551e5e 100644 --- a/consumerWebsite/routes/location.js +++ b/consumerWebsite/routes/location.js @@ -25,6 +25,7 @@ router.get("/", async (req, res, next) => { //add location router.post("/new", async (req, res, next) => { try { + console.log(req.body); const { name, added_by, description } = req.body; await addLocation(name, added_by, description); res.sendStatus(200)