mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 05:14:23 +00:00
various small changes + almost complete ticket gen
This commit is contained in:
@@ -14,6 +14,7 @@ const twoFA = new auth();
|
||||
const path = require( 'path' );
|
||||
|
||||
let responseObjects = {};
|
||||
let authOk = {};
|
||||
|
||||
module.exports = ( app, settings ) => {
|
||||
/*
|
||||
@@ -85,6 +86,14 @@ module.exports = ( app, settings ) => {
|
||||
responseObjects[ request.session.token ] = response;
|
||||
} );
|
||||
|
||||
app.get( '/admin/2fa/ping', ( request, response ) => {
|
||||
if ( authOk[ request.session.token ] === 'ok' ) {
|
||||
response.send( { 'status': 'ok' } );
|
||||
} else {
|
||||
response.send( '' );
|
||||
}
|
||||
} );
|
||||
|
||||
app.get( '/test/login', ( request, response ) => {
|
||||
request.session.loggedInAdmin = true;
|
||||
response.send( 'Logged in' );
|
||||
|
||||
@@ -14,7 +14,7 @@ class GETHandler {
|
||||
|
||||
}
|
||||
|
||||
handleCall ( call, query, session ) {
|
||||
handleCall ( call, query, session, settings ) {
|
||||
return new Promise( ( resolve, reject ) => {
|
||||
if ( call === 'getSeatplan' ) {
|
||||
db.getJSONDataSimple( 'seatplan', query.location ).then( data => {
|
||||
@@ -40,6 +40,8 @@ class GETHandler {
|
||||
} else {
|
||||
reject( { 'code': 400, 'message': 'Bad request, missing event query' } );
|
||||
}
|
||||
} else if ( call === 'getName' ) {
|
||||
resolve( { 'name': settings.name } );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ module.exports = ( app, settings ) => {
|
||||
'success_url': settings.yourDomain + '/payments/success',
|
||||
'cancel_url': settings.yourDomain + '/payments/canceled',
|
||||
'submit_type': 'book',
|
||||
'customer_email': req.body.customer.mail
|
||||
'customer_email': req.body.mail
|
||||
};
|
||||
|
||||
for ( let item in req.body.products ) {
|
||||
|
||||
@@ -14,22 +14,31 @@ const db = require( '../db/db.js' );
|
||||
class TicketGenerator {
|
||||
constructor () {
|
||||
this.ticketQueue = {};
|
||||
this.jobId = 0;
|
||||
this.isRunning = false;
|
||||
}
|
||||
|
||||
// TODO: Save to disk in case of crash of server / reboot / whatever
|
||||
// and continue processing once back online
|
||||
generateTicket ( event, data ) {
|
||||
|
||||
this.ticketQueue [ this.jobId ] = { 'event': event, 'data': data };
|
||||
this.jobId += 1;
|
||||
this.queueHandler();
|
||||
}
|
||||
|
||||
// TODO: Maybe move to subprocesses
|
||||
queueHandler () {
|
||||
if ( !this.isRunning ) {
|
||||
this.isRunning = true;
|
||||
this.ticketGenerator( this.ticketQueue[ Object.keys( this.ticketQueue )[ 0 ] ] ).then( res => {
|
||||
this.ticketGenerator( this.ticketQueue[ this.jobId ][ 'event' ], this.ticketQueue[ this.jobId ][ 'data' ] ).then( pdf => {
|
||||
console.log( pdf );
|
||||
// TODO: Maybe write to disk
|
||||
this.isRunning = false;
|
||||
this.queueHandler();
|
||||
} ).catch( error => {
|
||||
console.error( '[ PDF GENERATOR ] ERROR: ' + error );
|
||||
this.isRunning = false;
|
||||
this.queueHandler();
|
||||
// TODO: Add to FAILED db
|
||||
} );
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@ const getHandler = new geth();
|
||||
const path = require( 'path' );
|
||||
|
||||
// settings is missing in arguments which shouldn't pose any problem
|
||||
module.exports = ( app ) => {
|
||||
module.exports = ( app, settings ) => {
|
||||
// Add specific routes here to have them be checked first to not get general handling
|
||||
|
||||
app.get( '/getAPI/:call', ( req, res ) => {
|
||||
getHandler.handleCall( req.params.call, req.query, req.session ).then( data => {
|
||||
getHandler.handleCall( req.params.call, req.query, req.session, settings ).then( data => {
|
||||
if ( req.params.call === 'getReservedSeats' ) {
|
||||
let dat = data;
|
||||
dat[ 'reserved' ] = postHandler.getReservedSeats( req.query.event );
|
||||
|
||||
@@ -14,6 +14,7 @@ const twoFA = new auth();
|
||||
const path = require( 'path' );
|
||||
|
||||
let responseObjects = {};
|
||||
let authOk = {};
|
||||
|
||||
module.exports = ( app, settings ) => {
|
||||
app.post( '/api/reserveTicket', ( request, response ) => {
|
||||
@@ -55,7 +56,11 @@ module.exports = ( app, settings ) => {
|
||||
let tokType = twoFA.verifySimple( request.query.token );
|
||||
if ( tokType === 'standard' ) {
|
||||
request.session.loggedInUser = true;
|
||||
if ( responseObjects[ request.query.token ] ) {
|
||||
responseObjects[ request.query.token ].write( 'data: authenticated\n\n' );
|
||||
} else {
|
||||
authOk[ request.query.token ] = 'ok';
|
||||
}
|
||||
response.sendFile( path.join( __dirname + '/../ui/en/2fa/2faSimple.html' ) );
|
||||
} else if ( tokType === 'enhanced' ) {
|
||||
response.sendFile( path.join( __dirname + '/../ui/en/2fa/2faEnhanced.html' ) );
|
||||
@@ -68,7 +73,11 @@ module.exports = ( app, settings ) => {
|
||||
let verified = twoFA.verifyEnhanced( request.body.token, request.body.code );
|
||||
if ( verified ) {
|
||||
request.session.loggedInUser = true;
|
||||
if ( responseObjects[ request.body.token ] ) {
|
||||
responseObjects[ request.body.token ].write( 'data: authenticated\n\n' );
|
||||
} else {
|
||||
authOk[ request.body.token ] = 'ok';
|
||||
}
|
||||
response.send( 'ok' );
|
||||
} else response.send( 'wrong' );
|
||||
} );
|
||||
@@ -85,8 +94,20 @@ module.exports = ( app, settings ) => {
|
||||
responseObjects[ request.session.token ] = response;
|
||||
} );
|
||||
|
||||
app.get( '/user/2fa/ping', ( request, response ) => {
|
||||
if ( authOk[ request.session.token ] === 'ok' ) {
|
||||
response.send( { 'status': 'ok' } );
|
||||
} else {
|
||||
response.send( '' );
|
||||
}
|
||||
} );
|
||||
|
||||
app.get( '/user/logout', ( request, response ) => {
|
||||
request.session.loggedInUser = false;
|
||||
response.send( 'logoutOk' );
|
||||
} );
|
||||
|
||||
app.post( '/user/signup', ( request, response ) => {
|
||||
response.send( 'ok' );
|
||||
} );
|
||||
};
|
||||
@@ -3,5 +3,6 @@
|
||||
"twoFA": "enhanced",
|
||||
"db": "mysql",
|
||||
"payments": "stripe",
|
||||
"name": "libreevent",
|
||||
"yourDomain": "http://localhost:8081"
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
# Account view:
|
||||
- set page title based on settings
|
||||
|
||||
- make pricing groups changeable in UI (event categories)
|
||||
|
||||
- Fix text field overflow (text too big for box)
|
||||
@@ -8,6 +6,7 @@
|
||||
|
||||
- Implement Permission system
|
||||
|
||||
- Seat numbering
|
||||
|
||||
|
||||
- add webpack to project website to decrease file size
|
||||
- add webpack (or any other minifying tool) to project website to decrease file size (OPTIONAL)
|
||||
@@ -8,7 +8,7 @@
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div id="sideCartView" :style="'width: ' + width + 'vw; top: ' + height + 'vh;'">
|
||||
<div id="sideCartView">
|
||||
<h2>Cart</h2>
|
||||
<div v-if="Object.keys( cart ).length > 0" style="height: 100%; width: 100%;">
|
||||
<div class="scroll-wrapper">
|
||||
@@ -92,6 +92,8 @@ export default {
|
||||
position: fixed;
|
||||
right: 0;
|
||||
height: 100vh;
|
||||
top: 17vh;
|
||||
width: 25vw;
|
||||
background-color: var( --accent-background );
|
||||
color: var( --secondary-color );
|
||||
}
|
||||
|
||||
@@ -27,16 +27,21 @@ if ( prod ) {
|
||||
res.json().then( data => {
|
||||
userStore.setUserAuth( data.user );
|
||||
userStore.setAdminAuth( data.admin );
|
||||
|
||||
localStorage.setItem( 'url', '' );
|
||||
fetch( '/getAPI/getName' ).then( res => {
|
||||
res.json().then( data => {
|
||||
userStore.setPageName( data.name );
|
||||
app.use( router );
|
||||
app.mount( '#app' );
|
||||
} );
|
||||
} );
|
||||
localStorage.setItem( 'url', '' );
|
||||
} );
|
||||
} );
|
||||
} else {
|
||||
localStorage.setItem( 'url', 'http://localhost:8081' );
|
||||
userStore.setUserAuth( true );
|
||||
userStore.setAdminAuth( true );
|
||||
localStorage.setItem( 'name', 'libreevent' );
|
||||
app.use( router );
|
||||
app.mount( '#app' );
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ export default {
|
||||
name: 'admin',
|
||||
component: () => import( '../views/admin/AdminView.vue' ),
|
||||
meta: {
|
||||
title: 'Admin - libreevent',
|
||||
title: 'Admin - ',
|
||||
adminAuthRequired: true,
|
||||
},
|
||||
children: [
|
||||
@@ -21,7 +21,7 @@ export default {
|
||||
name: 'adminHome',
|
||||
component: () => import( '../views/admin/HomeView.vue' ),
|
||||
meta: {
|
||||
title: 'Home :: Admin - libreevent',
|
||||
title: 'Home :: Admin - ',
|
||||
adminAuthRequired: true,
|
||||
}
|
||||
},
|
||||
@@ -30,7 +30,7 @@ export default {
|
||||
name: 'adminLocations',
|
||||
component: () => import( '../views/admin/LocationsView.vue' ),
|
||||
meta: {
|
||||
title: 'Accounts :: Admin - libreevent',
|
||||
title: 'Accounts :: Admin - ',
|
||||
adminAuthRequired: true,
|
||||
permissions: 'root'
|
||||
}
|
||||
@@ -40,7 +40,7 @@ export default {
|
||||
name: 'adminPages',
|
||||
component: () => import( '../views/admin/PagesView.vue' ),
|
||||
meta: {
|
||||
title: 'Pages :: Admin - libreevent',
|
||||
title: 'Pages :: Admin - ',
|
||||
adminAuthRequired: true,
|
||||
}
|
||||
},
|
||||
@@ -49,7 +49,7 @@ export default {
|
||||
name: 'adminEvents',
|
||||
component: () => import( '../views/admin/EventsView.vue' ),
|
||||
meta: {
|
||||
title: 'Events :: Admin - libreevent',
|
||||
title: 'Events :: Admin - ',
|
||||
adminAuthRequired: true,
|
||||
},
|
||||
},
|
||||
@@ -58,7 +58,7 @@ export default {
|
||||
name: 'adminPlugins',
|
||||
component: () => import( '../views/admin/PluginsView.vue' ),
|
||||
meta: {
|
||||
title: 'Plugins :: Admin - libreevent',
|
||||
title: 'Plugins :: Admin - ',
|
||||
adminAuthRequired: true,
|
||||
}
|
||||
},
|
||||
@@ -67,7 +67,7 @@ export default {
|
||||
name: 'adminSettings',
|
||||
component: () => import( '../views/admin/SettingsView.vue' ),
|
||||
meta: {
|
||||
title: 'Admin - libreevent',
|
||||
title: 'Admin - ',
|
||||
adminAuthRequired: true,
|
||||
}
|
||||
},
|
||||
@@ -76,7 +76,7 @@ export default {
|
||||
name: 'eventDetails',
|
||||
component: () => import( '../views/admin/events/EventsDetailsView.vue' ),
|
||||
meta: {
|
||||
title: 'Event details :: Admin - libreevent',
|
||||
title: 'Event details :: Admin - ',
|
||||
adminAuthRequired: true,
|
||||
}
|
||||
},
|
||||
@@ -85,7 +85,7 @@ export default {
|
||||
name: 'eventAnalytics',
|
||||
component: () => import( '../views/admin/events/AnalyticsView.vue' ),
|
||||
meta: {
|
||||
title: 'Event analytics :: Admin - libreevent',
|
||||
title: 'Event analytics :: Admin - ',
|
||||
adminAuthRequired: true,
|
||||
}
|
||||
},
|
||||
|
||||
@@ -27,14 +27,13 @@ const router = createRouter( {
|
||||
routes,
|
||||
} );
|
||||
|
||||
|
||||
router.afterEach( ( to, from ) => {
|
||||
document.title = to.meta.title ? to.meta.title : 'libreevent';
|
||||
let userStore = useUserStore();
|
||||
document.title = to.meta.title ? to.meta.title + userStore.getPageName : 'libreevent';
|
||||
} );
|
||||
|
||||
let UserAccountPages = [ 'account' ];
|
||||
|
||||
let authRequired = false;
|
||||
|
||||
router.beforeEach( ( to, from ) => {
|
||||
let userStore = useUserStore();
|
||||
|
||||
@@ -21,7 +21,7 @@ export default [
|
||||
name: 'home',
|
||||
component: HomeView,
|
||||
meta: {
|
||||
title: 'Home - libreevent'
|
||||
title: 'Home - '
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -29,7 +29,7 @@ export default [
|
||||
name: 'tickets',
|
||||
component: () => import( '../views/purchasing/OrderView.vue' ),
|
||||
meta: {
|
||||
title: 'Order ticket - libreevent'
|
||||
title: 'Order ticket - '
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -37,7 +37,7 @@ export default [
|
||||
name: 'login',
|
||||
component: () => import( '../views/user/LoginView.vue' ),
|
||||
meta: {
|
||||
title: 'Login - libreevent'
|
||||
title: 'Login - '
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -45,7 +45,7 @@ export default [
|
||||
name: 'adminLogin',
|
||||
component: () => import( '../views/admin/AdminLoginView.vue' ),
|
||||
meta: {
|
||||
title: 'Login :: Admin - libreevent'
|
||||
title: 'Login :: Admin - '
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -53,7 +53,7 @@ export default [
|
||||
name: 'admin2FA',
|
||||
component: () => import( '../views/admin/TwoFA.vue' ),
|
||||
meta: {
|
||||
title: 'Two Factor Authentication :: Admin - libreevent'
|
||||
title: 'Two Factor Authentication :: Admin - '
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -61,7 +61,7 @@ export default [
|
||||
name: 'signup',
|
||||
component: () => import( '../views/user/SignupView.vue' ),
|
||||
meta: {
|
||||
title: 'Signup - libreevent'
|
||||
title: 'Signup - '
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -69,7 +69,7 @@ export default [
|
||||
name: 'account',
|
||||
component: () => import( '../views/user/AccountView.vue' ),
|
||||
meta: {
|
||||
title: 'Account - libreevent'
|
||||
title: 'Account - '
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -77,7 +77,7 @@ export default [
|
||||
name: '2fa',
|
||||
component: () => import( '../views/user/TwoFA.vue' ),
|
||||
meta: {
|
||||
title: 'Two Factor Authentication - libreevent'
|
||||
title: 'Two Factor Authentication - '
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -85,7 +85,7 @@ export default [
|
||||
name: 'ticketDetails',
|
||||
component: () => import( '../views/purchasing/TicketsDetailsView.vue' ),
|
||||
meta: {
|
||||
title: 'Details - libreevent',
|
||||
title: 'Details - ',
|
||||
transition: 'scale'
|
||||
}
|
||||
},
|
||||
@@ -94,7 +94,7 @@ export default [
|
||||
name: 'ticketOrder',
|
||||
component: () => import( '../views/purchasing/TicketsOrderingView.vue' ),
|
||||
meta: {
|
||||
title: 'Order ticket - libreevent',
|
||||
title: 'Order ticket - ',
|
||||
transition: 'scale'
|
||||
}
|
||||
},
|
||||
@@ -103,7 +103,7 @@ export default [
|
||||
name: 'cart',
|
||||
component: () => import( '../views/purchasing/CartView.vue' ),
|
||||
meta: {
|
||||
title: 'Cart - libreevent',
|
||||
title: 'Cart - ',
|
||||
transition: 'scale'
|
||||
}
|
||||
},
|
||||
@@ -112,7 +112,7 @@ export default [
|
||||
name: 'purchase',
|
||||
component: () => import( '@/views/purchasing/PurchaseView.vue' ),
|
||||
meta: {
|
||||
title: 'Purchase - libreevent',
|
||||
title: 'Purchase - ',
|
||||
transition: 'scale'
|
||||
}
|
||||
},
|
||||
@@ -121,7 +121,7 @@ export default [
|
||||
name: 'adminSeatplanEditor',
|
||||
component: () => import( '@/views/admin/events/EditorView.vue' ),
|
||||
meta: {
|
||||
title: 'Seatplan Editor :: Admin - libreevent',
|
||||
title: 'Seatplan Editor :: Admin - ',
|
||||
adminAuthRequired: true,
|
||||
}
|
||||
},
|
||||
@@ -130,7 +130,7 @@ export default [
|
||||
name: 'adminTicketEditor',
|
||||
component: () => import( '@/views/admin/events/TicketEditorView.vue' ),
|
||||
meta: {
|
||||
title: 'Ticket Editor :: Admin - libreevent',
|
||||
title: 'Ticket Editor :: Admin - ',
|
||||
adminAuthRequired: true,
|
||||
}
|
||||
},
|
||||
@@ -139,7 +139,7 @@ export default [
|
||||
name: 'NotFound',
|
||||
component: () => import( '@/views/404.vue' ),
|
||||
meta: {
|
||||
title: '404 - Page not found :: libreevent',
|
||||
title: '404 - Page not found :: ',
|
||||
transition: 'scale',
|
||||
}
|
||||
},
|
||||
|
||||
@@ -10,12 +10,13 @@
|
||||
import { defineStore } from "pinia";
|
||||
|
||||
export const useUserStore = defineStore ( 'user', {
|
||||
state: () => ( { 'isUserAuth': false, 'isAdminAuth': false, 'userData': {}, 'isTwoFACompliantUser': false, 'isTwoFACompliantAdmin': false } ),
|
||||
state: () => ( { 'isUserAuth': false, 'isAdminAuth': false, 'userData': {}, 'isTwoFACompliantUser': false, 'isTwoFACompliantAdmin': false, 'pageName': 'libreevent' } ),
|
||||
getters: {
|
||||
getUserAuthenticated: ( state ) => state.isUserAuth,
|
||||
getAdminAuthenticated: ( state ) => state.isAdminAuth,
|
||||
getUserTwoFACompliant: ( state ) => state.isTwoFACompliantUser,
|
||||
getAdminTwoFACompliant: ( state ) => state.isTwoFACompliantAdmin,
|
||||
getPageName: ( state ) => state.pageName,
|
||||
},
|
||||
actions: {
|
||||
setUserAuth ( auth ) {
|
||||
@@ -29,6 +30,9 @@ export const useUserStore = defineStore ( 'user', {
|
||||
},
|
||||
setAdmin2fa ( auth ) {
|
||||
this.isTwoFACompliantAdmin = auth;
|
||||
},
|
||||
setPageName ( name ) {
|
||||
this.pageName = name;
|
||||
}
|
||||
}
|
||||
} );
|
||||
@@ -66,6 +66,27 @@
|
||||
setTimeout( () => {
|
||||
this.$refs.notification.createNotification( 'Unsupported browser detected. Redirection might take longer to occur!', 20, 'warning', 'normal' );
|
||||
}, 300 );
|
||||
// ping server every 5s to check if logged in
|
||||
this.serverPing = setInterval( () => {
|
||||
fetch( '/admin/2fa/ping' ).then( res => {
|
||||
if ( res.status === 200 ) {
|
||||
res.json().then( data => {
|
||||
if ( data ) {
|
||||
if ( data.status === 'ok' ) {
|
||||
this.userStore.setUserAuth( true );
|
||||
this.$router.push( sessionStorage.getItem( 'redirect' ) ?? '/account' );
|
||||
}
|
||||
}
|
||||
} );
|
||||
} else {
|
||||
console.error( 'Request failed' );
|
||||
this.$refs.notification.createNotification( 'We are sorry, but an error occurred. You will not be redirected automatically', 300, 'error', 'normal' );
|
||||
}
|
||||
} ).catch( error => {
|
||||
console.error( error );
|
||||
this.$refs.notification.createNotification( 'We are sorry, but an error occurred. You will not be redirected automatically', 300, 'error', 'normal' );
|
||||
} );
|
||||
}, 5000 );
|
||||
}
|
||||
let code = sessionStorage.getItem( '2faCode' ) ? sessionStorage.getItem( '2faCode' ) : '';
|
||||
this.code = { '1': code.slice( 0, 3 ), '2': code.substring( 3 ) };
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<template>
|
||||
<div class="order">
|
||||
<h1>Order tickets</h1>
|
||||
<div class="order-app" v-if="events">
|
||||
<div class="order-app" v-if="Object.keys( orderedEvents ).length">
|
||||
<ul>
|
||||
<li v-for="event in orderedEvents">
|
||||
<router-link to="/tickets/details" class="ticket" @click="setActiveTicket( event.eventID );">
|
||||
@@ -95,7 +95,7 @@
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
events: { 'test':{ 'name': 'TestEvent', 'description': 'This is a description for the TestEvent to test multiline support and proper positioning of the Fields', 'freeSeats': 2, 'maxSeats': 2, 'date':'2023-07-31T09:00:00Z', 'startingPrice':15, 'location': 'TestLocation', 'eventID': 'test', 'currency': 'CHF', 'logo': new URL( '/src/assets/logo.png', import.meta.url ).href }, 'test2':{ 'name': 'TestEvent2', 'description': 'This is a description for the TestEvent to test multiline support and proper positioning of the Fields', 'freeSeats': 2, 'maxSeats': 2, 'date':'2023-08-01T09:00:00Z', 'startingPrice':15, 'location': 'TestLocation', 'eventID': 'test2', 'currency': 'CHF', 'logo': new URL( '/src/assets/logo.png', import.meta.url ).href } },
|
||||
events: { 'test':{ 'name': 'TestEvent', 'description': 'This is a description for the TestEvent to test multiline support and proper positioning of the Fields', 'freeSeats': 2, 'maxSeats': 2, 'date':'2023-08-31T09:00:00Z', 'startingPrice':15, 'location': 'TestLocation', 'eventID': 'test', 'currency': 'CHF', 'logo': new URL( '/src/assets/logo.png', import.meta.url ).href }, 'test2':{ 'name': 'TestEvent2', 'description': 'This is a description for the TestEvent to test multiline support and proper positioning of the Fields', 'freeSeats': 2, 'maxSeats': 2, 'date':'2023-08-15T09:00:00Z', 'startingPrice':15, 'location': 'TestLocation', 'eventID': 'test2', 'currency': 'CHF', 'logo': new URL( '/src/assets/logo.png', import.meta.url ).href } },
|
||||
today: new Date().getTime()
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user