mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 13:24:24 +00:00
fix jsondb bug -> missing promise resolution
This commit is contained in:
@@ -1 +1 @@
|
|||||||
{"libreevent_temp":{"1":{"timestamp":"Wed Aug 23 2023 15:38:21 GMT+0200 (Central European Summer Time)"},"2":{"user_id":"u9vAXhbP3iHHN5JxtRUJy4afYN1Sml1G","timestamp":"Wed Aug 23 2023 15:38:38 GMT+0200 (Central European Summer Time)","data":"{\"test4\":{\"secAr5s10\":{\"id\":\"secAr5s10\",\"component\":1,\"ticketOption\":\"2\",\"eventID\":\"test4\",\"category\":\"1\",\"name\":\"Row 6, Seat 11\"}}}"}},"libreevent_admin":{},"libreevent_orders":{},"libreevent_users":{}}
|
{"libreevent_temp":{},"libreevent_admin":{},"libreevent_orders":{},"libreevent_users":{"1":{"email":"info@janishutz.com","first_name":"t","name":"t","two_fa":"","user_data":"{\"country\":\"t\"}","marketing":null,"mail_confirmed":"true"}}}
|
||||||
@@ -23,6 +23,7 @@ class JSONDB {
|
|||||||
this.db = data[ 'db' ] ?? { 'libreevent_temp': {}, 'libreevent_admin': {}, 'libreevent_orders': {}, 'libreevent_users': {} };
|
this.db = data[ 'db' ] ?? { 'libreevent_temp': {}, 'libreevent_admin': {}, 'libreevent_orders': {}, 'libreevent_users': {} };
|
||||||
this.dbIndex = data[ 'index' ] ?? { 'libreevent_temp': 0, 'libreevent_admin': 0, 'libreevent_orders': 0, 'libreevent_users': 0 };
|
this.dbIndex = data[ 'index' ] ?? { 'libreevent_temp': 0, 'libreevent_admin': 0, 'libreevent_orders': 0, 'libreevent_users': 0 };
|
||||||
this.db[ 'libreevent_temp' ] = {};
|
this.db[ 'libreevent_temp' ] = {};
|
||||||
|
this.saveToDisk();
|
||||||
console.log( '[ JSON-DB ] Database initialized successfully' );
|
console.log( '[ JSON-DB ] Database initialized successfully' );
|
||||||
return 'connection';
|
return 'connection';
|
||||||
}
|
}
|
||||||
@@ -119,6 +120,7 @@ class JSONDB {
|
|||||||
this.dbIndex[ table ] += 1;
|
this.dbIndex[ table ] += 1;
|
||||||
this.db[ table ][ this.dbIndex[ table ] ] = operation.data;
|
this.db[ table ][ this.dbIndex[ table ] ] = operation.data;
|
||||||
this.saveToDisk();
|
this.saveToDisk();
|
||||||
|
resolve( true );
|
||||||
} else if ( operation.command === 'updateData' ) {
|
} else if ( operation.command === 'updateData' ) {
|
||||||
if ( !operation.property || !operation.searchQuery ) reject( 'Refusing to run destructive command: Missing Constraints' );
|
if ( !operation.property || !operation.searchQuery ) reject( 'Refusing to run destructive command: Missing Constraints' );
|
||||||
else {
|
else {
|
||||||
@@ -131,6 +133,7 @@ class JSONDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.saveToDisk();
|
this.saveToDisk();
|
||||||
|
resolve( true );
|
||||||
} else if ( operation.command === 'deleteData' ) {
|
} else if ( operation.command === 'deleteData' ) {
|
||||||
if ( !operation.property || !operation.searchQuery ) reject( 'Refusing to run destructive command: Missing Constraints' );
|
if ( !operation.property || !operation.searchQuery ) reject( 'Refusing to run destructive command: Missing Constraints' );
|
||||||
else {
|
else {
|
||||||
@@ -141,6 +144,7 @@ class JSONDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.saveToDisk();
|
this.saveToDisk();
|
||||||
|
resolve( true );
|
||||||
} else if ( operation.command === 'InnerJoin' ) {
|
} else if ( operation.command === 'InnerJoin' ) {
|
||||||
// TODO: Finish those when actually needed
|
// TODO: Finish those when actually needed
|
||||||
} else if ( operation.command === 'LeftJoin' ) {
|
} else if ( operation.command === 'LeftJoin' ) {
|
||||||
|
|||||||
@@ -155,7 +155,15 @@ module.exports = ( app, settings ) => {
|
|||||||
mailManager.sendMail( request.body.mail, await twoFA.generateSignupEmail( tok, settings.yourDomain, settings.name ), 'Confirm your email', settings.mailSender );
|
mailManager.sendMail( request.body.mail, await twoFA.generateSignupEmail( tok, settings.yourDomain, settings.name ), 'Confirm your email', settings.mailSender );
|
||||||
} )();
|
} )();
|
||||||
pwdmanager.hashPassword( request.body.password ).then( hash => {
|
pwdmanager.hashPassword( request.body.password ).then( hash => {
|
||||||
db.writeDataSimple( 'users', 'email', request.body.mail, { 'email': request.body.mail, 'pass': hash, 'first_name': request.body.firstName, 'name': request.body.name, 'two_fa': 'disabled', 'user_data': JSON.stringify( { 'country': request.body.country } ), 'marketing': request.body.newsletter ? generator.generateToken( 60 ) : null } ).then( () => {
|
db.writeDataSimple( 'users', 'email', request.body.mail, {
|
||||||
|
'email': request.body.mail,
|
||||||
|
'pass': hash,
|
||||||
|
'first_name': request.body.firstName,
|
||||||
|
'name': request.body.name,
|
||||||
|
'two_fa': 'disabled',
|
||||||
|
'user_data': JSON.stringify( { 'country': request.body.country } ),
|
||||||
|
'marketing': request.body.newsletter ? generator.generateToken( 60 ) : null
|
||||||
|
} ).then( () => {
|
||||||
request.session.loggedInUser = true;
|
request.session.loggedInUser = true;
|
||||||
request.session.username = request.body.mail;
|
request.session.username = request.body.mail;
|
||||||
response.send( 'ok' );
|
response.send( 'ok' );
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"init":false,
|
"init":true,
|
||||||
"twoFA":"enforce",
|
"twoFA":"enforce",
|
||||||
"setupKey":"hello world",
|
"setupKey":"hello world",
|
||||||
"twoFAMode":"enhanced",
|
"twoFAMode":"enhanced",
|
||||||
|
|||||||
@@ -16,13 +16,14 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="mail">Email</label><br>
|
<label for="mail">Email</label><br>
|
||||||
<input type="email" v-model="formData[ 'mail' ]" name="mail" id="mail" required><br><br>
|
<input type="email" v-model="formData[ 'mail' ]" name="mail" id="mail" required @keyup="emailLiveChecker()"><br><br>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<label for="country">Country</label><br>
|
<label for="country">Country</label><br>
|
||||||
<input type="text" v-model="formData[ 'country' ]" name="country" id="country" required><br><br>
|
<input type="text" v-model="formData[ 'country' ]" name="country" id="country" required><br><br>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<p v-if="emailStatus" class="email-status">{{ emailStatus }}</p>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="firstName">First name</label><br>
|
<label for="firstName">First name</label><br>
|
||||||
@@ -68,7 +69,8 @@
|
|||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
formData: {}
|
formData: {},
|
||||||
|
emailStatus: '',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
@@ -78,6 +80,58 @@
|
|||||||
...mapStores( useUserStore )
|
...mapStores( useUserStore )
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
emailLiveChecker () {
|
||||||
|
setTimeout( () => {
|
||||||
|
if ( this.checkEmail() ) {
|
||||||
|
this.emailStatus = '';
|
||||||
|
} else {
|
||||||
|
this.emailStatus = 'Invalid email address';
|
||||||
|
}
|
||||||
|
}, 100 );
|
||||||
|
},
|
||||||
|
checkEmail () {
|
||||||
|
const mail = this.formData.mail ?? '';
|
||||||
|
let stat = { 'atPos': 0, 'topLevelPos': 0 };
|
||||||
|
for ( let l in mail ) {
|
||||||
|
if ( stat[ 'atPos' ] > 0 ) {
|
||||||
|
if ( mail[ l ] === '@' ) {
|
||||||
|
return false;
|
||||||
|
} else if ( mail[ l ] === '.' ) {
|
||||||
|
if ( stat[ 'topLevelPos' ] > 0 ) {
|
||||||
|
if ( l > stat[ 'topLevelPos' ] + 2 ) {
|
||||||
|
stat[ 'topLevelPos' ] = parseInt( l );
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ( l > stat[ 'atPos' ] + 2 ) {
|
||||||
|
stat[ 'topLevelPos' ] = parseInt( l );
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ( !( /[a-z]/.test( mail[ l ] ) || /[A-Z]/.test( mail[ l ] ) || /[1-9]/.test( mail[ l ] ) ) ) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ( mail[ l ] === '@' ) {
|
||||||
|
if ( l > 2 ) {
|
||||||
|
stat[ 'atPos' ] = parseInt( l );
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if ( !( /[a-z]/.test( mail[ l ] ) || /[A-Z]/.test( mail[ l ] ) || /[1-9]/.test( mail[ l ] ) || mail[ l ] === '.' ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if ( mail.length > stat[ 'topLevelPos' ] + 2 && stat[ 'topLevelPos' ] > 0 && stat[ 'atPos' ] > 0 ) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
signup () {
|
signup () {
|
||||||
if ( !this.formData.mail ) {
|
if ( !this.formData.mail ) {
|
||||||
this.$refs.notification.createNotification( 'An email address is required to sign up', 5, 'error', 'normal' );
|
this.$refs.notification.createNotification( 'An email address is required to sign up', 5, 'error', 'normal' );
|
||||||
@@ -112,8 +166,9 @@
|
|||||||
'charset': 'utf-8'
|
'charset': 'utf-8'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
console.log( 'signup initiated' )
|
||||||
fetch( localStorage.getItem( 'url' ) + '/user/signup', fetchOptions ).then( res => {
|
fetch( localStorage.getItem( 'url' ) + '/user/signup', fetchOptions ).then( res => {
|
||||||
console.log( res );
|
console.log( res )
|
||||||
res.text().then( status => {
|
res.text().then( status => {
|
||||||
if ( status === 'ok' ) {
|
if ( status === 'ok' ) {
|
||||||
this.$refs.notification.cancelNotification( progress );
|
this.$refs.notification.cancelNotification( progress );
|
||||||
@@ -138,6 +193,13 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.email-status {
|
||||||
|
margin-top: -10px;
|
||||||
|
color: red;
|
||||||
|
font-style: italic;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
.login {
|
.login {
|
||||||
background-color: green;
|
background-color: green;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
Reference in New Issue
Block a user