mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 13:24:24 +00:00
add some setup routes already
This commit is contained in:
@@ -52,10 +52,11 @@ const settings = JSON.parse( fs.readFileSync( path.join( __dirname + '/config/se
|
||||
// Vue SSR and gets its support files (e.g. CSS and JS files) from
|
||||
// the /home/supportFiles/:file route plus its assets from the /otherAssets/:file
|
||||
// route).
|
||||
|
||||
app.get( '/', ( req, res ) => {
|
||||
res.sendFile( path.join( __dirname + '/ui/home/active/en/index.html' ) );
|
||||
} );
|
||||
if ( settings.init ) {
|
||||
app.get( '/', ( req, res ) => {
|
||||
res.sendFile( path.join( __dirname + '/ui/home/active/en/index.html' ) );
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
// Set up static routes for static file serving (performance wise not
|
||||
@@ -94,6 +95,7 @@ if ( settings.init ) {
|
||||
require( './backend/payments/paymentRoutes.js' )( app, settings ); // payment routes
|
||||
require( './backend/plugins/pluginLoader.js' )( app, settings ); // plugin loader
|
||||
} else {
|
||||
console.log( '[ Setup ] Loading setup routes' );
|
||||
require( './setup/setupRoutes.js' )( app, settings ); // setup routes
|
||||
file = path.join( __dirname + '/webapp/setup/dist/index.html' );
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"init":true,"twoFA":"enforce","setupKey":"hello world","twoFAMode":"enhanced","db":"json","payments":"stripe","name":"libreevent","yourDomain":"http://localhost:8080","mailSender":"libreevent <info@libreevent.janishutz.com>","maxTickets":10,"currency":"CHF","gcInterval":300,"ticketTimeout":900,"startPage":"default","version":"1.0.0"}
|
||||
{"init":false,"twoFA":"enforce","setupKey":"hello world","twoFAMode":"enhanced","db":"json","payments":"stripe","name":"libreevent","yourDomain":"http://localhost:8080","mailSender":"libreevent <info@libreevent.janishutz.com>","maxTickets":10,"currency":"CHF","gcInterval":300,"ticketTimeout":900,"startPage":"default","version":"1.0.0"}
|
||||
@@ -8,19 +8,34 @@
|
||||
*/
|
||||
|
||||
let db = null;
|
||||
const fs = require( 'fs' );
|
||||
const path = require( 'path' );
|
||||
const bodyParser = require( 'body-parser' );
|
||||
// const db = require( '../backend/db/db.js' );
|
||||
|
||||
module.exports = ( app, settings ) => {
|
||||
/*
|
||||
Admin login route that checks the password
|
||||
Setup start route that checks if setup key was correct
|
||||
*/
|
||||
|
||||
app.get( '/setup/start', ( request, response ) => {
|
||||
if ( request.query.token === settings.setupToken ) {
|
||||
app.post( '/setup/start', bodyParser.json(), ( request, response ) => {
|
||||
if ( request.body.token === '' + fs.readFileSync( path.join( __dirname + '/../setupkey.txt' ) ) ) {
|
||||
response.send( 'ok' );
|
||||
} else {
|
||||
response.send( 'incorrect' );
|
||||
response.status( 400 ).send( 'incorrect' );
|
||||
}
|
||||
} );
|
||||
|
||||
app.get( '/setup/getKeyStatus', ( req, res ) => {
|
||||
if ( req.session.setupKeyOk ) {
|
||||
res.send( 'ok' );
|
||||
} else {
|
||||
res.status( 403 ).send( 'not authorized' );
|
||||
}
|
||||
} );
|
||||
|
||||
app.get( '/test/login', ( req, res ) => {
|
||||
req.session.setupKeyOk = true;
|
||||
res.send( 'ok' );
|
||||
} );
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
klbjdfgsgsdjhlfkgfshjkgsfhjsiutuitpwergvuilavlsuv
|
||||
Reference in New Issue
Block a user