mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 05:14:23 +00:00
mysql db partially integrated
This commit is contained in:
@@ -60,7 +60,6 @@ require( './admin/routes.js' )( app, settings ); // admin routes
|
||||
require( './backend/userRoutes.js' )( app, settings ); // user routes
|
||||
|
||||
app.use( ( request, response ) => {
|
||||
console.log( 'index fallback' );
|
||||
response.sendFile( path.join( __dirname + '/../webapp/dist/index.html' ) );
|
||||
} );
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
const bcrypt = require( 'bcrypt' );
|
||||
const db = require( '../db/db.js' );
|
||||
|
||||
module.exports.checkpassword = function checkpassword ( username, password ) {
|
||||
module.exports.checkpassword = function checkpassword ( email, password ) {
|
||||
return new Promise( resolve => {
|
||||
db.getData( 'user', username ).then( data => {
|
||||
db.getDataSimple( 'user', 'email', email ).then( data => {
|
||||
bcrypt.compare( password, data ).then( data => {
|
||||
resolve( data );
|
||||
} );
|
||||
|
||||
@@ -10,14 +10,35 @@
|
||||
const path = require( 'path' );
|
||||
const fs = require( 'fs' );
|
||||
|
||||
module.exports.getData = function getData ( db, searchQuery ) {
|
||||
const settings = JSON.parse( fs.readFileSync( path.join( __dirname + '/../../config/settings.config.json' ) ) );
|
||||
|
||||
const dbRef = { 'user': 'libreevent_users', 'admin': 'libreevent_admin', 'order': 'libreevent_orders' };
|
||||
|
||||
let dbh;
|
||||
|
||||
if ( settings.db === 'mysql' ) {
|
||||
const dbsoft = require( './mysqldb.js' );
|
||||
dbh = new dbsoft();
|
||||
} else {
|
||||
const dbsoft = require( './jsondb.js' );
|
||||
dbh = new dbsoft();
|
||||
}
|
||||
|
||||
module.exports.getDataSimple = function getData ( db, column, searchQuery ) {
|
||||
return new Promise( resolve => {
|
||||
dbh.query( { 'command': 'getFilteredData', 'property': column, 'searchQuery': searchQuery }, dbRef[ db ] ).then( data => {
|
||||
console.log( data );
|
||||
} ).catch( error => {
|
||||
console.error( error );
|
||||
} );
|
||||
resolve( '$2b$05$ElMYWoMjk7567lXkIkee.e.6cxCrWU4gkfuNLB8gmGYLQQPm7gT3O' );
|
||||
} );
|
||||
};
|
||||
|
||||
module.exports.writeData = function writeData ( db ) {
|
||||
module.exports.writeDataSimple = function writeData ( db, column, searchQuery ) {
|
||||
return new Promise( ( resolve, reject ) => {
|
||||
|
||||
} );
|
||||
};
|
||||
|
||||
module.exports.getJSONData = function getData ( file ) {
|
||||
|
||||
@@ -8,14 +8,15 @@
|
||||
*/
|
||||
|
||||
const mysql = require( 'mysql' );
|
||||
const db = require( './db.js' );
|
||||
const fs = require( 'fs' );
|
||||
const path = require( 'path' );
|
||||
|
||||
// If the connection does not work for you, you will need to add your ip
|
||||
// to the whitelist of the database
|
||||
|
||||
class SQLDB {
|
||||
constructor () {
|
||||
this.sqlConnection = mysql.createConnection( db.getJSONDataSync( '/config/db.config.secret.json' ) );
|
||||
this.sqlConnection = mysql.createConnection( JSON.parse( fs.readFileSync( path.join( __dirname + '/../../config/db.config.secret.json' ) ) ) );
|
||||
}
|
||||
|
||||
connect () {
|
||||
@@ -63,7 +64,6 @@ class SQLDB {
|
||||
|
||||
query ( operation, table ) {
|
||||
return new Promise( ( resolve, reject ) => {
|
||||
// getAllData, getFilteredData, InnerJoin, LeftJoin, RightJoin, addData, updateData, deleteData, checkDataAvailability, fullCustomCommand (NOTE: SANITISATION WILL NOT TAKE PLACE!)
|
||||
/*
|
||||
Possible operation.command values (all need the table argument of the method call):
|
||||
- getAllData: no additional instructions needed
|
||||
@@ -102,9 +102,13 @@ class SQLDB {
|
||||
sanitised by the function)
|
||||
- operation.property (the column to search for the value),
|
||||
- operation.searchQuery (the value to search for [will be sanitised by method])
|
||||
|
||||
- checkDataAvailability:
|
||||
- operation.property (the column to search for the value),
|
||||
- operation.searchQuery (the value to search for [will be sanitised by method])
|
||||
|
||||
- fullCustomCommand:
|
||||
- operation.query (the SQL instruction to be executed) --> NOTE: This command will not be sanitised, so use only with proper sanitisation!
|
||||
*/
|
||||
let command = '';
|
||||
if ( operation.command === 'getAllData' ) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"init": false,
|
||||
"twoFA": "standard"
|
||||
"twoFA": "standard",
|
||||
"db": "mysql"
|
||||
}
|
||||
1
website/dist/css/navstyle.css
vendored
1
website/dist/css/navstyle.css
vendored
@@ -17,7 +17,6 @@
|
||||
position: fixed;
|
||||
display: block;
|
||||
z-index: 2;
|
||||
width: 100%;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 1;
|
||||
|
||||
Reference in New Issue
Block a user