mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 13:24:24 +00:00
add root accounts
This commit is contained in:
@@ -88,6 +88,16 @@ class GETHandler {
|
||||
resolve( this.settings.currency );
|
||||
} else if ( call === 'getAdminAccounts' ) {
|
||||
db.getData( 'admin' ).then( data => {
|
||||
if ( data[ 0 ] ) {
|
||||
resolve( { 'data': data, 'status': 'ok' } );
|
||||
} else {
|
||||
resolve( { 'data': {}, 'status': 'empty' } );
|
||||
}
|
||||
} ).catch( err => {
|
||||
reject( { 'code': 500, 'message': 'ERR_DB: ' + err } );
|
||||
} );
|
||||
} else if ( call === 'getRootAccountDetails' ) {
|
||||
db.getJSONData( 'rootAccount' ).then( data => {
|
||||
resolve( data );
|
||||
} ).catch( err => {
|
||||
reject( { 'code': 500, 'message': 'ERR_DB: ' + err } );
|
||||
|
||||
@@ -20,19 +20,27 @@ const db = require( '../backend/db/db.js' );
|
||||
|
||||
module.exports.checkpassword = ( username, password ) => {
|
||||
return new Promise( resolve => {
|
||||
db.getDataSimple( 'admin', 'email', username ).then( data => {
|
||||
if ( data ) {
|
||||
if ( data[ 0 ] ) {
|
||||
bcrypt.compare( password, data[ 0 ].pass ).then( res => {
|
||||
resolve( { 'status': res, 'twoFA': data[ 0 ].two_fa } );
|
||||
} );
|
||||
if ( username === 'root' ) {
|
||||
db.getJSONData( 'rootAccount' ).then( account => {
|
||||
bcrypt.compare( password, account.pass ).then( res => {
|
||||
resolve( { 'status': res, 'twoFA': true } );
|
||||
} );
|
||||
} );
|
||||
} else {
|
||||
db.getDataSimple( 'admin', 'email', username ).then( data => {
|
||||
if ( data ) {
|
||||
if ( data[ 0 ] ) {
|
||||
bcrypt.compare( password, data[ 0 ].pass ).then( res => {
|
||||
resolve( { 'status': res, 'twoFA': data[ 0 ].two_fa } );
|
||||
} );
|
||||
} else {
|
||||
resolve( false );
|
||||
}
|
||||
} else {
|
||||
resolve( false );
|
||||
}
|
||||
} else {
|
||||
resolve( false );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
}
|
||||
} );
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user