add some setup routes already

This commit is contained in:
2023-09-06 15:27:50 +02:00
parent 667b542893
commit 4afeb7a146
12 changed files with 136 additions and 130 deletions

53
LICENSE
View File

@@ -619,56 +619,3 @@ Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@@ -7,6 +7,9 @@
- Seat numbering!!
- Website: Add ids to titles
- Update files to import when deploying for included json files instead of secret.json files
- Fix text field overflow (text too big for box)
@@ -18,3 +21,61 @@
- FUTURE add multi-language support
- FUTURE: Guest purchase
- FUTURE: add webpack (or any other minifying tool) to project website to decrease file size (OPTIONAL)
GPL Stuff:
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
libreevent - Free and Open Source Event Management and Ticketing
Solution
Copyright (C) 2023 Janis Hutz
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
libreevent Copyright (C) 2023 Janis Hutz
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@@ -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 ) => {
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' );
}

View File

@@ -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"}

View File

@@ -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' );
} );
};

View File

@@ -0,0 +1 @@
klbjdfgsgsdjhlfkgfshjkgsfhjsiutuitpwergvuilavlsuv

View File

@@ -43,15 +43,6 @@ export default {
setupAuthRequired: true,
}
},
{
path: 'page',
name: 'setupPage',
component: () => import( '../views/SetupPageView.vue' ),
meta: {
title: 'Landing page :: Setup - libreevent',
setupAuthRequired: true,
}
},
{
path: 'complete',
name: 'setupComplete',

View File

@@ -14,24 +14,55 @@
<p>Let's start the setup by entering the setup key below! You may define a setup key in the <i>setupkey.txt</i> file of libreevent. See <a href="https://libreevent.janishutz.com/docs/setup/installation" target="_blank">here</a> for more instructions</p>
<form>
<label for="key">Your setup key</label><br>
<input type="text" v-model="formData[ 'key' ]" required name="key" id="key">
<input type="text" v-model="formData[ 'token' ]" required name="key" id="key">
</form>
<button @click="setup();" class="button">Start setup</button>
<notifications ref="notification" location="topright" size="bigger"></notifications>
</div>
</template>
<script>
import notifications from '../components/notifications.vue';
export default {
data() {
return {
formData: {},
}
},
components: {
notifications,
},
methods: {
setup () {
const options = {
method: 'post',
body: JSON.stringify( this.formData ),
headers: {
'Content-Type': 'application/json',
'charset': 'utf-8'
}
};
fetch( '/setup/start', options ).then( res => {
if ( res.status === 200 ) {
this.$router.push( '/setup' );
} else {
this.$refs.notification.createNotification( 'Setup key incorrect!', 5, 'error', 'normal' );
}
} );
}
},
created() {
fetch( '/setup/getKeyStatus' ).then( res => {
if ( res.status === 200 ) {
res.text().then( text => {
if ( text === 'ok' ) {
this.$router.push( '/setup' );
}
} );
}
} );
}
}
</script>

View File

@@ -1,51 +0,0 @@
<!--
* libreevent - SetupPageView.vue
*
* Created by Janis Hutz 05/14/2023, Licensed under the GPL V3 License
* https://janishutz.com, development@janishutz.com
*
*
-->
<template>
<div class="wrapper">
<div class="content">
<h1>Landing page</h1>
<p>The landing page is the page your customers see when they visit your webpage. You may select a page template <a href="https://libreevent.janishutz.com/docs/homepage/templates" target="_blank">here</a>.</p>
<p>You may find more infos about this part <a href="https://libreevent.janishutz.com/docs/setup/setup#page-setup" target="_blank">here</a></p>
<label for="template">Choose a template</label><br>
<select name="template" id="template">
<option v-for="option in options" :key="option.id" :value="option.id">{{ option.name }}</option>
</select><br>
<button @click="submit()" class="button">Continue</button>
</div>
</div>
</template>
<script>
import { useBackendStore } from '@/stores/backendStore.js';
import { mapStores } from 'pinia';
export default {
data () {
return {
options: {
'default': { 'id': 'default', 'name': 'Default' },
'none': { 'id': 'none', 'name': 'Configure later (will show an empty page)' },
},
websiteName: 'libreevent',
}
},
computed: {
...mapStores( useBackendStore )
},
methods: {
submit () {
this.backendStore.addVisitedSetupPages( 'complete', true );
this.$router.push( '/setup/complete' );
}
},
};
</script>

View File

@@ -169,8 +169,8 @@
}
},
proceed () {
this.backendStore.addVisitedSetupPages( 'page', true );
this.$router.push( 'page' );
this.backendStore.addVisitedSetupPages( 'complete', true );
this.$router.push( 'complete' );
}
},
};

View File

@@ -15,8 +15,6 @@
<a v-else class="inactive">Basic Setup</a> |
<router-link to="/setup/root" v-if="backendStore.getVisitedSetupPages[ 'root' ]">Root account</router-link>
<a v-else class="inactive">Root account</a> |
<router-link to="/setup/page" v-if="backendStore.getVisitedSetupPages[ 'page' ]">Landing page</router-link>
<a v-else class="inactive">Landing page</a> |
<router-link to="/setup/complete" v-if="backendStore.getVisitedSetupPages[ 'complete' ]">Complete</router-link>
<a v-else class="inactive">Complete</a>
</nav>
@@ -45,6 +43,17 @@
},
created () {
this.backendStore.loadVisitedSetupPages();
fetch( '/setup/getKeyStatus' ).then( res => {
if ( res.status === 200 ) {
res.text().then( text => {
if ( text != 'ok' ) {
this.$router.push( '/' );
}
} );
} else {
this.$router.push( '/' );
}
} );
},
};
</script>