mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 13:24:24 +00:00
2fa settings now available
This commit is contained in:
@@ -22,7 +22,7 @@ module.exports.checkpassword = function checkpassword ( email, password ) {
|
|||||||
if ( data ) {
|
if ( data ) {
|
||||||
if ( data[ 0 ] ) {
|
if ( data[ 0 ] ) {
|
||||||
bcrypt.compare( password, data[ 0 ].pass ).then( res => {
|
bcrypt.compare( password, data[ 0 ].pass ).then( res => {
|
||||||
resolve( res );
|
resolve( { 'status': res, 'twoFA': data[ 0 ].two_fa } );
|
||||||
} );
|
} );
|
||||||
} else {
|
} else {
|
||||||
resolve( false );
|
resolve( false );
|
||||||
|
|||||||
@@ -50,9 +50,8 @@ module.exports = ( app, settings ) => {
|
|||||||
if ( request.body.mail && request.body.password ) {
|
if ( request.body.mail && request.body.password ) {
|
||||||
pwdmanager.checkpassword( request.body.mail, request.body.password ).then( data => {
|
pwdmanager.checkpassword( request.body.mail, request.body.password ).then( data => {
|
||||||
request.session.username = request.body.mail;
|
request.session.username = request.body.mail;
|
||||||
// TODO: Check if user has 2fa enabled
|
if ( data.status ) {
|
||||||
if ( data ) {
|
if ( data.twoFA === 'simple' ) {
|
||||||
if ( settings.twoFA === 'standard' ) {
|
|
||||||
( async () => {
|
( async () => {
|
||||||
let tok = twoFA.registerStandardAuthentication()[ 'token' ];
|
let tok = twoFA.registerStandardAuthentication()[ 'token' ];
|
||||||
let ipRetrieved = request.headers[ 'x-forwarded-for' ];
|
let ipRetrieved = request.headers[ 'x-forwarded-for' ];
|
||||||
@@ -61,7 +60,7 @@ module.exports = ( app, settings ) => {
|
|||||||
request.session.token = tok;
|
request.session.token = tok;
|
||||||
response.send( { 'status': '2fa' } );
|
response.send( { 'status': '2fa' } );
|
||||||
} )();
|
} )();
|
||||||
} else if ( settings.twoFA === 'enhanced' ) {
|
} else if ( data.twoFA === 'enhanced' ) {
|
||||||
( async () => {
|
( async () => {
|
||||||
let res = twoFA.registerEnhancedAuthentication();
|
let res = twoFA.registerEnhancedAuthentication();
|
||||||
let ipRetrieved = request.headers[ 'x-forwarded-for' ];
|
let ipRetrieved = request.headers[ 'x-forwarded-for' ];
|
||||||
@@ -141,7 +140,6 @@ module.exports = ( app, settings ) => {
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
app.post( '/user/signup', bodyParser.json(), ( request, response ) => {
|
app.post( '/user/signup', bodyParser.json(), ( request, response ) => {
|
||||||
// TODO: Send mail to confirm email address
|
|
||||||
if ( request.body.password && request.body.password === request.body.password2 && request.body.firstName && request.body.name && request.body.country && request.body.mail ) {
|
if ( request.body.password && request.body.password === request.body.password2 && request.body.firstName && request.body.name && request.body.country && request.body.mail ) {
|
||||||
db.checkDataAvailability( 'users', 'email', request.body.mail ).then( status => {
|
db.checkDataAvailability( 'users', 'email', request.body.mail ).then( status => {
|
||||||
if ( status ) {
|
if ( status ) {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ setTimeout( () => {
|
|||||||
}, 1000 );
|
}, 1000 );
|
||||||
|
|
||||||
setTimeout( () => {
|
setTimeout( () => {
|
||||||
db.writeDataSimple( 'user', 'email', 'info@janishutz.com', { 'email': 'info@janishutz.com', 'pass': '$2b$05$ElMYWoMjk7567lXkIkee.e.6cxCrWU4gkfuNLB8gmGYLQQPm7gT3O', 'name': 'Hutz', 'first_name': 'Janis', 'two_fa': 'true' } );
|
db.writeDataSimple( 'user', 'email', 'info@janishutz.com', { 'email': 'info@janishutz.com', 'pass': '$2b$05$ElMYWoMjk7567lXkIkee.e.6cxCrWU4gkfuNLB8gmGYLQQPm7gT3O', 'name': 'Hutz', 'first_name': 'Janis', 'two_fa': 'enhanced' } );
|
||||||
}, 1000 );
|
}, 1000 );
|
||||||
|
|
||||||
setTimeout( () => {
|
setTimeout( () => {
|
||||||
|
|||||||
@@ -15,6 +15,14 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
|
methods: {
|
||||||
|
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -50,6 +50,7 @@
|
|||||||
res.json().then( data => {
|
res.json().then( data => {
|
||||||
if ( data.status ) {
|
if ( data.status ) {
|
||||||
this.accountData = data.data;
|
this.accountData = data.data;
|
||||||
|
console.log( data );
|
||||||
if ( !data.data.mail_confirmed ) {
|
if ( !data.data.mail_confirmed ) {
|
||||||
setTimeout( () => {
|
setTimeout( () => {
|
||||||
this.$refs.notification.createNotification( 'Your account is unverified. Please confirm your email using the link we have sent to your email!', 20, 'info', 'normal' );
|
this.$refs.notification.createNotification( 'Your account is unverified. Please confirm your email using the link we have sent to your email!', 20, 'info', 'normal' );
|
||||||
|
|||||||
Reference in New Issue
Block a user