mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 05:14:23 +00:00
working 2fa system
This commit is contained in:
@@ -1,9 +1,16 @@
|
||||
# Account view:
|
||||
- Maybe add multi-language support
|
||||
|
||||
- make pricing groups changeable in UI (event categories)
|
||||
|
||||
- Create password changing endpoint (to reset forgotten pwd)
|
||||
- Add Admin profile (page to change account settings per person like changing pwd)
|
||||
|
||||
|
||||
- Fix text field overflow (text too big for box)
|
||||
- Other optimisation for seat plan editor
|
||||
|
||||
|
||||
- Implement Permission system
|
||||
|
||||
- Seat numbering
|
||||
|
||||
@@ -116,6 +116,15 @@ export default [
|
||||
transition: 'scale'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/guest',
|
||||
name: 'guestPurchase',
|
||||
component: () => import( '@/views/purchasing/GuestPurchaseView.vue' ),
|
||||
meta: {
|
||||
title: 'Guest purchase - ',
|
||||
transition: 'scale'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/admin/seatplan',
|
||||
name: 'adminSeatplanEditor',
|
||||
|
||||
@@ -32,64 +32,72 @@
|
||||
...mapStores( useUserStore ),
|
||||
},
|
||||
created () {
|
||||
if ( !!window.EventSource ) {
|
||||
setTimeout( () => {
|
||||
let startNotification = this.$refs.notification.createNotification( 'Connecting to status service', 20, 'progress', 'normal' );
|
||||
let source = new EventSource( localStorage.getItem( 'url' ) + '/admin/2fa/check', { withCredentials: true } );
|
||||
|
||||
let self = this;
|
||||
if ( this.userStore.getAdminTwoFACompliant ) {
|
||||
if ( !!window.EventSource ) {
|
||||
setTimeout( () => {
|
||||
let startNotification = this.$refs.notification.createNotification( 'Connecting to status service', 20, 'progress', 'normal' );
|
||||
let source = new EventSource( localStorage.getItem( 'url' ) + '/admin/2fa/check', { withCredentials: true } );
|
||||
|
||||
let self = this;
|
||||
|
||||
source.onmessage = ( e ) => {
|
||||
if ( e.data === 'authenticated' ) {
|
||||
self.userStore.setAdminAuth( true );
|
||||
self.$router.push( '/admin' );
|
||||
console.log( e.data );
|
||||
source.onmessage = ( e ) => {
|
||||
if ( e.data === 'authenticated' ) {
|
||||
self.userStore.setAdminAuth( true );
|
||||
self.$router.push( '/admin' );
|
||||
console.log( e.data );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
source.onopen = e => {
|
||||
self.$refs.notification.createNotification( 'Connected to status service', 5, 'ok', 'normal' );
|
||||
self.$refs.notification.cancelNotification( startNotification );
|
||||
};
|
||||
|
||||
source.addEventListener( 'error', function(e) {
|
||||
if ( e.eventPhase == EventSource.CLOSED ) source.close();
|
||||
|
||||
if ( e.target.readyState == EventSource.CLOSED ) {
|
||||
console.log( e );
|
||||
source.onopen = e => {
|
||||
self.$refs.notification.createNotification( 'Connected to status service', 5, 'ok', 'normal' );
|
||||
self.$refs.notification.cancelNotification( startNotification );
|
||||
self.$refs.notification.createNotification( 'Could not connect to status service', 5, 'error', 'normal' );
|
||||
}
|
||||
}, false)
|
||||
}, 300 );
|
||||
} else {
|
||||
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' );
|
||||
};
|
||||
|
||||
source.addEventListener( 'error', function(e) {
|
||||
if ( e.eventPhase == EventSource.CLOSED ) source.close();
|
||||
|
||||
if ( e.target.readyState == EventSource.CLOSED ) {
|
||||
console.log( e );
|
||||
self.$refs.notification.cancelNotification( startNotification );
|
||||
self.$refs.notification.createNotification( 'Could not connect to status service', 5, 'error', 'normal' );
|
||||
}
|
||||
}, false)
|
||||
}, 300 );
|
||||
} else {
|
||||
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' );
|
||||
} );
|
||||
} 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' );
|
||||
}
|
||||
} ).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 );
|
||||
} );
|
||||
}, 5000 );
|
||||
}
|
||||
let code = sessionStorage.getItem( '2faCode' ) ? sessionStorage.getItem( '2faCode' ) : '';
|
||||
this.code = { '1': code.slice( 0, 3 ), '2': code.substring( 3 ) };
|
||||
} else {
|
||||
if ( this.userStore.getAdminAuthenticated ) {
|
||||
this.$router.push( '/admin' );
|
||||
} else {
|
||||
this.$router.push( '/admin/login' );
|
||||
}
|
||||
}
|
||||
let code = sessionStorage.getItem( '2faCode' ) ? sessionStorage.getItem( '2faCode' ) : '';
|
||||
this.code = { '1': code.slice( 0, 3 ), '2': code.substring( 3 ) };
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -5,4 +5,16 @@
|
||||
* https://janishutz.com, development@janishutz.com
|
||||
*
|
||||
*
|
||||
-->
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<h1>Guest purchase</h1>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
|
||||
}
|
||||
</script>
|
||||
@@ -217,6 +217,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
loadData () {
|
||||
// TODO: Also load the customer data from server!
|
||||
this.cartNotEmpty = false;
|
||||
let cart = JSON.parse( localStorage.getItem( 'cart' ) );
|
||||
|
||||
|
||||
@@ -1,7 +1,19 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1>Account</h1>
|
||||
|
||||
<p>Welcome, {{ accountData.first_name }} {{ accountData.name }}!</p>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
Email
|
||||
</td>
|
||||
<td>
|
||||
{{ accountData.email }}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<notifications ref="notification" location="topright" size="bigger"></notifications>
|
||||
<popups ref="popups" size="big" @data="data => { savePwd( data ) }"></popups>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -10,4 +22,50 @@
|
||||
nav {
|
||||
display: initial;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
<script>
|
||||
import { useUserStore } from '@/stores/userStore';
|
||||
import { mapStores } from 'pinia';
|
||||
import notifications from '@/components/notifications/notifications.vue';
|
||||
import popups from '@/components/notifications/popups.vue';
|
||||
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
accountData: {},
|
||||
}
|
||||
},
|
||||
components: {
|
||||
notifications,
|
||||
popups,
|
||||
},
|
||||
computed: {
|
||||
...mapStores( useUserStore )
|
||||
},
|
||||
created () {
|
||||
// TODO: Also get all orders of user (using join functions)
|
||||
fetch( '/user/details' ).then( res => {
|
||||
if ( res.status === 200 ) {
|
||||
res.json().then( data => {
|
||||
if ( data.status ) {
|
||||
this.accountData = data.data;
|
||||
console.log( data.data );
|
||||
} else {
|
||||
this.userStore.setUserAuth( false );
|
||||
this.userStore.setUser2fa( false );
|
||||
this.$router.push( '/login' );
|
||||
}
|
||||
} );
|
||||
} else if ( res.status === 403 ) {
|
||||
this.userStore.setUserAuth( false );
|
||||
this.userStore.setUser2fa( false );
|
||||
this.$router.push( '/login' );
|
||||
}
|
||||
} );
|
||||
if ( this.userStore.getUserTwoFACompliant ) {
|
||||
this.userStore.setUser2fa( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -33,62 +33,70 @@
|
||||
...mapStores( useUserStore ),
|
||||
},
|
||||
created () {
|
||||
if ( !!window.EventSource ) {
|
||||
setTimeout( () => {
|
||||
let startNotification = this.$refs.notification.createNotification( 'Connecting to status service', 20, 'progress', 'normal' );
|
||||
let source = new EventSource( localStorage.getItem( 'url' ) + '/user/2fa/check', { withCredentials: true } );
|
||||
|
||||
let self = this;
|
||||
if ( this.userStore.getUserTwoFACompliant ) {
|
||||
if ( !!window.EventSource ) {
|
||||
setTimeout( () => {
|
||||
let startNotification = this.$refs.notification.createNotification( 'Connecting to status service', 20, 'progress', 'normal' );
|
||||
let source = new EventSource( localStorage.getItem( 'url' ) + '/user/2fa/check', { withCredentials: true } );
|
||||
|
||||
let self = this;
|
||||
|
||||
source.onmessage = ( e ) => {
|
||||
if ( e.data === 'authenticated' ) {
|
||||
self.userStore.setUserAuth( true );
|
||||
self.$router.push( sessionStorage.getItem( 'redirect' ) ?? '/account' );
|
||||
source.onmessage = ( e ) => {
|
||||
if ( e.data === 'authenticated' ) {
|
||||
self.userStore.setUserAuth( true );
|
||||
self.$router.push( sessionStorage.getItem( 'redirect' ) ?? '/account' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
source.onopen = e => {
|
||||
self.$refs.notification.createNotification( 'Connected to status service', 5, 'ok', 'normal' );
|
||||
self.$refs.notification.cancelNotification( startNotification );
|
||||
};
|
||||
|
||||
source.addEventListener( 'error', function( e ) {
|
||||
if ( e.eventPhase == EventSource.CLOSED ) source.close();
|
||||
|
||||
if ( e.target.readyState == EventSource.CLOSED ) {
|
||||
source.onopen = e => {
|
||||
self.$refs.notification.createNotification( 'Connected to status service', 5, 'ok', 'normal' );
|
||||
self.$refs.notification.cancelNotification( startNotification );
|
||||
self.$refs.notification.createNotification( 'Could not connect to status service', 5, 'error', 'normal' );
|
||||
}
|
||||
}, false)
|
||||
}, 300 );
|
||||
} else {
|
||||
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( '/user/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' );
|
||||
};
|
||||
|
||||
source.addEventListener( 'error', function( e ) {
|
||||
if ( e.eventPhase == EventSource.CLOSED ) source.close();
|
||||
|
||||
if ( e.target.readyState == EventSource.CLOSED ) {
|
||||
self.$refs.notification.cancelNotification( startNotification );
|
||||
self.$refs.notification.createNotification( 'Could not connect to status service', 5, 'error', 'normal' );
|
||||
}
|
||||
}, false)
|
||||
}, 300 );
|
||||
} else {
|
||||
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( '/user/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' );
|
||||
} );
|
||||
} 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' );
|
||||
}
|
||||
} ).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 );
|
||||
} );
|
||||
}, 5000 );
|
||||
}
|
||||
let code = sessionStorage.getItem( '2faCode' ) ? sessionStorage.getItem( '2faCode' ) : '';
|
||||
this.code = { '1': code.slice( 0, 3 ), '2': code.substring( 3 ) };
|
||||
} else {
|
||||
if ( this.userStore.getUserAuthenticated ) {
|
||||
this.$router.push( '/account' );
|
||||
} else {
|
||||
this.$router.push( '/login' );
|
||||
}
|
||||
}
|
||||
let code = sessionStorage.getItem( '2faCode' ) ? sessionStorage.getItem( '2faCode' ) : '';
|
||||
this.code = { '1': code.slice( 0, 3 ), '2': code.substring( 3 ) };
|
||||
},
|
||||
unmounted() {
|
||||
clearInterval( this.serverPing );
|
||||
|
||||
Reference in New Issue
Block a user