mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 13:24:24 +00:00
ticket gen working + various changes
This commit is contained in:
@@ -28,10 +28,9 @@ module.exports = ( app, settings ) => {
|
||||
if ( request.body.mail && request.body.password ) {
|
||||
pwdmanager.checkpassword( request.body.mail, request.body.password ).then( data => {
|
||||
request.session.username = request.body.mail;
|
||||
if ( data ) {
|
||||
if ( data.status ) {
|
||||
request.session.username = request.body.mail;
|
||||
// TODO: Check if user has 2fa enabled
|
||||
if ( settings.twoFA === 'standard' ) {
|
||||
if ( data.twoFA === 'simple' ) {
|
||||
( async () => {
|
||||
let tok = twoFA.registerStandardAuthentication()[ 'token' ];
|
||||
let ipRetrieved = request.headers[ 'x-forwarded-for' ];
|
||||
@@ -40,7 +39,7 @@ module.exports = ( app, settings ) => {
|
||||
request.session.token = tok;
|
||||
response.send( { 'status': '2fa' } );
|
||||
} )();
|
||||
} else if ( settings.twoFA === 'enhanced' ) {
|
||||
} else if ( data.twoFA === 'enhanced' ) {
|
||||
( async () => {
|
||||
let res = twoFA.registerEnhancedAuthentication();
|
||||
let ipRetrieved = request.headers[ 'x-forwarded-for' ];
|
||||
@@ -50,7 +49,7 @@ module.exports = ( app, settings ) => {
|
||||
response.send( { 'status': '2fa+', 'code': res.code } );
|
||||
} )();
|
||||
} else {
|
||||
request.session.loggedInUser = true;
|
||||
request.session.loggedInAdmin = true;
|
||||
response.send( { 'status': 'ok' } );
|
||||
}
|
||||
} else {
|
||||
@@ -63,7 +62,6 @@ module.exports = ( app, settings ) => {
|
||||
} );
|
||||
|
||||
app.get( '/admin/2fa', ( request, response ) => {
|
||||
// TODO: Add multi language
|
||||
let tokType = twoFA.verifySimple( request.query.token );
|
||||
if ( tokType === 'standard' ) {
|
||||
request.session.loggedInAdmin = true;
|
||||
|
||||
@@ -42,7 +42,13 @@ class GETHandler {
|
||||
} );
|
||||
} else if ( call === 'getLocations' ) {
|
||||
db.getJSONData( 'locations' ).then( data => {
|
||||
resolve( data );
|
||||
resolve( data ?? {} );
|
||||
} ).catch( error => {
|
||||
reject( { 'code': 500, 'error': error } );
|
||||
} );
|
||||
} else if ( call === 'getTicketTemplate' ) {
|
||||
db.getJSONDataSimple( 'tickets', query.ticket ).then( data => {
|
||||
resolve( data ?? {} );
|
||||
} ).catch( error => {
|
||||
reject( { 'code': 500, 'error': error } );
|
||||
} );
|
||||
|
||||
@@ -24,7 +24,7 @@ module.exports.checkpassword = ( username, password ) => {
|
||||
if ( data ) {
|
||||
if ( data[ 0 ] ) {
|
||||
bcrypt.compare( password, data[ 0 ].pass ).then( res => {
|
||||
resolve( res );
|
||||
resolve( { 'status': res, 'twoFA': data[ 0 ].two_fa } );
|
||||
} );
|
||||
} else {
|
||||
resolve( false );
|
||||
|
||||
Reference in New Issue
Block a user