app api fix

This commit is contained in:
2023-09-22 09:53:35 +02:00
parent d37fcda0db
commit a6c6a4feb0
5 changed files with 17 additions and 7 deletions

View File

@@ -31,16 +31,16 @@ module.exports = ( app ) => {
pwHandler.checkpassword( req.body.email, req.body.password ).then( status => { pwHandler.checkpassword( req.body.email, req.body.password ).then( status => {
if ( status ) { if ( status ) {
if ( status.status ) { if ( status.status ) {
db.getDataSimple( 'orders', 'order_name', req.body.ticketID.slice( 0, req.body.ticketID.indexOf( '_' ) ) ).then( dat => { db.getDataSimple( 'orders', 'order_name', req.body.ticketID.slice( 0, req.body.ticketID.lastIndexOf( '_' ) ) ).then( dat => {
if ( dat[ 0 ] ) { if ( dat[ 0 ] ) {
const tickets = JSON.parse( dat[ 0 ][ 'tickets' ] ); const tickets = JSON.parse( dat[ 0 ][ 'tickets' ] );
const event = req.body.ticketID.slice( req.body.ticketID.indexOf( '_' ) + 1, req.body.ticketID.indexOf( '-' ) ); const event = req.body.ticketID.slice( req.body.ticketID.lastIndexOf( '_' ) + 1, req.body.ticketID.lastIndexOf( '-' ) );
const ticket = req.body.ticketID.slice( req.body.ticketID.indexOf( '-' ) + 1, req.body.ticketID.length ); const ticket = req.body.ticketID.slice( req.body.ticketID.lastIndexOf( '-' ) + 1, req.body.ticketID.length );
if ( tickets[ event ] ) { if ( tickets[ event ] ) {
if ( tickets[ event ][ ticket ] ) { if ( tickets[ event ][ ticket ] ) {
if ( !tickets[ event ][ ticket ][ 'invalidated' ] ) { if ( !tickets[ event ][ ticket ][ 'invalidated' ] ) {
tickets[ event ][ ticket ][ 'invalidated' ] = true; tickets[ event ][ ticket ][ 'invalidated' ] = true;
db.writeDataSimple( 'orders', 'order_name', req.body.ticketID.slice( 0, req.body.ticketID.indexOf( '_' ) ), { 'tickets': JSON.stringify( tickets ) } ); db.writeDataSimple( 'orders', 'order_name', req.body.ticketID.slice( 0, req.body.ticketID.lastIndexOf( '_' ) ), { 'tickets': JSON.stringify( tickets ) } );
res.send( 'ticketValid' ); res.send( 'ticketValid' );
} else { } else {
res.send( 'ticketInvalid' ); res.send( 'ticketInvalid' );

View File

@@ -3,7 +3,7 @@
"setupDone":true, "setupDone":true,
"twoFA":"enforce", "twoFA":"enforce",
"twoFAMode":"enhanced", "twoFAMode":"enhanced",
"db":"json", "db":"mysql",
"payments":"stripe", "payments":"stripe",
"name":"libreevent", "name":"libreevent",
"yourDomain":"http://localhost:8080", "yourDomain":"http://localhost:8080",

File diff suppressed because one or more lines are too long

View File

@@ -14,6 +14,7 @@
<div v-else-if="contentType === 'text'" class="options"> <div v-else-if="contentType === 'text'" class="options">
<h3>{{ data.message }}</h3> <h3>{{ data.message }}</h3>
<input type="text" v-model="data.selected"> <input type="text" v-model="data.selected">
<p>{{ info }}</p>
<div class="button-wrapper"> <div class="button-wrapper">
<button @click="closePopup( 'ok' )" title="Save changes">Save</button> <button @click="closePopup( 'ok' )" title="Save changes">Save</button>
<button @click="closePopup( 'cancel' )" title="Cancel changes">Cancel</button> <button @click="closePopup( 'cancel' )" title="Cancel changes">Cancel</button>
@@ -108,10 +109,19 @@
return { return {
contentType: 'dropdown', contentType: 'dropdown',
data: {}, data: {},
info: '',
} }
}, },
methods: { methods: {
closePopup( message ) { closePopup( message ) {
if ( this.data.options.disallowedCharacters ) {
for ( let letter in this.data.selected ) {
if ( this.data.options.disallowedCharacters.includes( this.data.selected[ letter ] ) ) {
this.info = `Illegal character "${ this.data.selected[ letter ] }"`;
return false;
}
}
}
$( '#popup-backdrop' ).fadeOut( 300 ); $( '#popup-backdrop' ).fadeOut( 300 );
if ( message ) { if ( message ) {
this.$emit( 'data', { 'data': this.data.selected, 'status': message } ); this.$emit( 'data', { 'data': this.data.selected, 'status': message } );

View File

@@ -158,7 +158,7 @@
}, },
addEvent () { addEvent () {
this.currentPopup = 'add'; this.currentPopup = 'add';
this.$refs.popup.openPopup( 'Please give the new event a name for internal use', {}, 'text' ); this.$refs.popup.openPopup( 'Please give the new event a name for internal use', { 'disallowedCharacters': [ '_', '-' ] }, 'text' );
}, },
setActiveTicket ( id ) { setActiveTicket ( id ) {
sessionStorage.setItem( 'selectedTicket', id ); sessionStorage.setItem( 'selectedTicket', id );