2fa settings now available

This commit is contained in:
2023-08-05 12:45:05 +02:00
parent 2c18ee6f61
commit 2812ab9055
5 changed files with 14 additions and 7 deletions

View File

@@ -22,7 +22,7 @@ module.exports.checkpassword = function checkpassword ( email, 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 );

View File

@@ -50,9 +50,8 @@ 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;
// TODO: Check if user has 2fa enabled
if ( data ) {
if ( settings.twoFA === 'standard' ) {
if ( data.status ) {
if ( data.twoFA === 'simple' ) {
( async () => {
let tok = twoFA.registerStandardAuthentication()[ 'token' ];
let ipRetrieved = request.headers[ 'x-forwarded-for' ];
@@ -61,7 +60,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' ];
@@ -141,7 +140,6 @@ module.exports = ( app, settings ) => {
} );
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 ) {
db.checkDataAvailability( 'users', 'email', request.body.mail ).then( status => {
if ( status ) {

View File

@@ -15,7 +15,7 @@ setTimeout( () => {
}, 1000 );
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 );
setTimeout( () => {

View File

@@ -15,6 +15,14 @@
<script>
export default {
methods: {
},
data() {
return {}
},
created() {
}
}
</script>

View File

@@ -50,6 +50,7 @@
res.json().then( data => {
if ( data.status ) {
this.accountData = data.data;
console.log( data );
if ( !data.data.mail_confirmed ) {
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' );