From 34194e65d221f1457d8d9b14adbdc6a9929a5650 Mon Sep 17 00:00:00 2001 From: Julian Gassner Date: Wed, 5 Feb 2025 16:48:57 +0000 Subject: [PATCH] Update messages --- backend/internal/mfa.js | 5 +++-- frontend/js/app/user/form.ejs | 9 +++++---- frontend/js/app/user/form.js | 8 ++++++++ frontend/js/i18n/messages.json | 9 +++++++-- frontend/js/login/ui/login.ejs | 6 +++--- 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/backend/internal/mfa.js b/backend/internal/mfa.js index 314fc80c..4daf3bba 100644 --- a/backend/internal/mfa.js +++ b/backend/internal/mfa.js @@ -30,10 +30,11 @@ module.exports = { .where('user_id', userId) .first() .then((auth) => { + console.log(auth); if (!auth) { throw new error.AuthError('User not found.'); } - return auth.mfa_enabled === 1; + return auth.mfa_enabled === true; }); }, createMfaSecretForUser: (userId) => { @@ -68,7 +69,7 @@ module.exports = { return authModel .query() .where('user_id', userId) - .update({ mfa_enabled: 1 }) + .update({ mfa_enabled: true }) .then(() => true); }); }, diff --git a/frontend/js/app/user/form.ejs b/frontend/js/app/user/form.ejs index 98a741d1..4d21acf7 100644 --- a/frontend/js/app/user/form.ejs +++ b/frontend/js/app/user/form.ejs @@ -27,11 +27,12 @@
- - + + +
diff --git a/frontend/js/app/user/form.js b/frontend/js/app/user/form.js index 1b3c5b76..ffde610c 100644 --- a/frontend/js/app/user/form.js +++ b/frontend/js/app/user/form.js @@ -16,6 +16,7 @@ module.exports = Mn.View.extend({ save: 'button.save', error: '.secret-error', addMfa: '.add-mfa', + mfaLabel: '.mfa-label', // added binding mfaValidation: '.mfa-validation-container', // added binding qrInstructions: '.qr-instructions' // added binding for instructions }, @@ -99,6 +100,8 @@ module.exports = Mn.View.extend({ view.ui.addMfa.replaceWith(`QR Code`); view.ui.qrInstructions.show(); view.ui.mfaValidation.show(); + // Add required attribute once MFA is activated + view.ui.mfaValidation.find('input[name="mfa_validation"]').attr('required', true); }) .catch(err => { view.ui.error.text(err.message).show(); @@ -140,12 +143,17 @@ module.exports = Mn.View.extend({ .then(response => { if (response.active) { view.ui.addMfa.hide(); + view.ui.mfaLabel.hide(); view.ui.qrInstructions.hide(); view.ui.mfaValidation.hide(); + // Remove required attribute if MFA is active & field is hidden + view.ui.mfaValidation.find('input[name="mfa_validation"]').removeAttr('required'); } else { view.ui.addMfa.show(); + view.ui.mfaLabel.show(); view.ui.qrInstructions.hide(); view.ui.mfaValidation.hide(); + view.ui.mfaValidation.find('input[name="mfa_validation"]').removeAttr('required'); } }) .catch(err => { diff --git a/frontend/js/i18n/messages.json b/frontend/js/i18n/messages.json index cbf4cb66..110d1189 100644 --- a/frontend/js/i18n/messages.json +++ b/frontend/js/i18n/messages.json @@ -2,7 +2,6 @@ "en": { "str": { "email-address": "Email address", - "mfa": "Multi factor authentication token", "username": "Username", "password": "Password", "sign-in": "Sign in", @@ -38,9 +37,15 @@ "all": "All", "any": "Any" }, + "mfa": { + "mfa": "Multi Factor Authentication", + "add-mfa": "Generate secret", + "mfa-setup-instruction": "Scan this QR code in your authenticator app to set up MFA and then enter the current MFA code in the input field.", + "mfa-token": "Multi factor authentication token" + }, "login": { "title": "Login to your account", - "mfa_required_text": "Please enter your MFA token to continue" + "mfa-required-text": "Please enter your MFA token to continue" }, "main": { "app": "Nginx Proxy Manager", diff --git a/frontend/js/login/ui/login.ejs b/frontend/js/login/ui/login.ejs index 60da27dc..ec15a82c 100644 --- a/frontend/js/login/ui/login.ejs +++ b/frontend/js/login/ui/login.ejs @@ -26,9 +26,9 @@