mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 05:14:23 +00:00
add some setup routes already
This commit is contained in:
@@ -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' );
|
||||
} );
|
||||
};
|
||||
Reference in New Issue
Block a user