WIP token
This commit is contained in:
30
consumerWebsite/functions/apiDatabase.js
Normal file
30
consumerWebsite/functions/apiDatabase.js
Normal file
@ -0,0 +1,30 @@
|
||||
const { sequelize } = require("../database/mySql.js");
|
||||
const { apikeyModel } = require("../database/model/apikeyModel.js");
|
||||
const { userModel } = require("../database/model/userModel.js");
|
||||
const { Op, Sequelize } = require("sequelize");
|
||||
|
||||
async function getUser() {
|
||||
const user = await userModel.findAll();
|
||||
return user;
|
||||
}
|
||||
|
||||
async function addUser(user) {
|
||||
//console.log(user);
|
||||
await userModel.create(user);
|
||||
}
|
||||
|
||||
async function getAPIKey() {
|
||||
const apikey = await apikeyModel.findAll();
|
||||
return apikey;
|
||||
}
|
||||
|
||||
async function addAPIKey(apikey) {
|
||||
await apikeyModel.create(apikey);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getUser,
|
||||
addUser,
|
||||
getAPIKey,
|
||||
addAPIKey,
|
||||
};
|
37
consumerWebsite/functions/bcrypt.js
Normal file
37
consumerWebsite/functions/bcrypt.js
Normal file
@ -0,0 +1,37 @@
|
||||
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.
|
||||
});
|
||||
|
||||
*/
|
||||
async function hashPassword(password) {
|
||||
return await bcrypt.hash(password, saltRounds);
|
||||
}
|
||||
|
||||
async function hashAPIKey(apikey) {
|
||||
return await bcrypt.hash(apikey, saltRounds);
|
||||
}
|
||||
|
||||
|
||||
|
||||
module.exports = {
|
||||
hashPassword,
|
||||
hashAPIKey,
|
||||
};
|
17
consumerWebsite/functions/generateUUID.js
Normal file
17
consumerWebsite/functions/generateUUID.js
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
const crypto = require('crypto');
|
||||
Calling the UUID method returns a UUID of standard length that you can use in your program.
|
||||
|
||||
let uuid = crypto.randomUUID();
|
||||
console.log(uuid);
|
||||
|
||||
*/
|
||||
const crypto = require('crypto');
|
||||
|
||||
|
||||
async function generateUUID() {
|
||||
let uuid = crypto.randomUUID();
|
||||
return uuid;
|
||||
}
|
||||
|
||||
module.exports = { generateUUID };
|
Reference in New Issue
Block a user