mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 05:14:23 +00:00
add password hashing function + easier prod
This commit is contained in:
@@ -18,10 +18,16 @@
|
|||||||
const bcrypt = require( 'bcrypt' );
|
const bcrypt = require( 'bcrypt' );
|
||||||
const db = require( '../backend/db/db.js' );
|
const db = require( '../backend/db/db.js' );
|
||||||
|
|
||||||
module.exports.checkpassword = function checkpassword ( username, password ) {
|
module.exports.checkpassword = ( username, password ) => {
|
||||||
return new Promise( resolve => {
|
return new Promise( resolve => {
|
||||||
db.getDataSimple( 'admin', 'email', username ).then( data => {
|
db.getDataSimple( 'admin', 'email', username ).then( data => {
|
||||||
resolve( bcrypt.compareSync( password, data ) );
|
resolve( bcrypt.compareSync( password, data ) );
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.hashPassword = ( password ) => {
|
||||||
|
return new Promise( resolve => {
|
||||||
|
resolve( bcrypt.hashSync( password, 10 ) );
|
||||||
|
} );
|
||||||
};
|
};
|
||||||
@@ -24,4 +24,10 @@ module.exports.checkpassword = function checkpassword ( email, password ) {
|
|||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.hashPassword = ( password ) => {
|
||||||
|
return new Promise( resolve => {
|
||||||
|
resolve( bcrypt.hashSync( password, 10 ) );
|
||||||
|
} );
|
||||||
};
|
};
|
||||||
@@ -186,8 +186,6 @@ export default {
|
|||||||
document.documentElement.classList.add( 'light' );
|
document.documentElement.classList.add( 'light' );
|
||||||
this.theme = '☽';
|
this.theme = '☽';
|
||||||
}
|
}
|
||||||
// localStorage.setItem( 'url', 'http://localhost:8081' );
|
|
||||||
localStorage.setItem( 'url', '' );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -19,21 +19,24 @@ app.use( createPinia() );
|
|||||||
|
|
||||||
let userStore = useUserStore();
|
let userStore = useUserStore();
|
||||||
|
|
||||||
let prod = true;
|
let prod = false;
|
||||||
|
|
||||||
if ( prod ) {
|
if ( prod ) {
|
||||||
fetch( '/api/getAuth' ).then( res => {
|
fetch( '/api/getAuth' ).then( res => {
|
||||||
// fetch( 'http://localhost:8081/api/getAuth' ).then( res => {
|
// fetch( 'http://localhost:8081/api/getAuth' ).then( res => {
|
||||||
res.json().then( data => {
|
res.json().then( data => {
|
||||||
userStore.setUserAuth( data.user );
|
userStore.setUserAuth( data.user );
|
||||||
userStore.setAdminAuth( data.admin );
|
userStore.setAdminAuth( data.admin );
|
||||||
|
|
||||||
app.use( router );
|
app.use( router );
|
||||||
app.mount( '#app' );
|
app.mount( '#app' );
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
localStorage.setItem( 'url', '' );
|
||||||
} else {
|
} else {
|
||||||
// userStore.setUserAuth( true );
|
localStorage.setItem( 'url', 'http://localhost:8081' );
|
||||||
|
userStore.setUserAuth( true );
|
||||||
|
userStore.setAdminAuth( true );
|
||||||
app.use( router );
|
app.use( router );
|
||||||
app.mount( '#app' );
|
app.mount( '#app' );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user