Node.js based forum software built for the modern web
remove email only login (#10030)
Julian Lam01bd8a8694b0
diff --git a/public/language/en-GB/admin/settings/user.json b/public/language/en-GB/admin/settings/user.jsonindex 7923bf8cbe..7695bdddae 100644--- a/public/language/en-GB/admin/settings/user.json+++ b/public/language/en-GB/admin/settings/user.json@@ -6,7 +6,6 @@"allow-login-with": "Allow login with","allow-login-with.username-email": "Username or Email","allow-login-with.username": "Username Only",- "allow-login-with.email": "Email Only","account-settings": "Account Settings","gdpr_enabled": "Enable GDPR consent collection","gdpr_enabled_help": "When enabled, all new registrants will be required to explicitly give consent for data collection and usage under the <a href=\"https://ec.europa.eu/info/priorities/justice-and-fundamental-rights/data-protection/2018-reform-eu-data-protection-rules/eu-data-protection-rules_en\">General Data Protection Regulation (GDPR)</a>. <strong>Note</strong>: Enabling GDPR does not force pre-existing users to provide consent. To do so, you will need to install the GDPR plugin.",diff --git a/public/language/en-GB/login.json b/public/language/en-GB/login.jsonindex c0ae9b7624..5421ccc307 100644--- a/public/language/en-GB/login.json+++ b/public/language/en-GB/login.json@@ -1,7 +1,6 @@{"username-email": "Username / Email","username": "Username",- "email": "Email","remember_me": "Remember Me?","forgot_password": "Forgot Password?","alternative_logins": "Alternative Logins",diff --git a/src/controllers/index.js b/src/controllers/index.jsindex dc23e6918f..896a4a8e5f 100644--- a/src/controllers/index.js+++ b/src/controllers/index.js@@ -130,9 +130,10 @@ Controllers.login = async function (req, res) {return helpers.redirect(res, { external: data.authentication[0].url });}+ // Re-auth challenge, pre-fill usernameif (req.loggedIn) {- const userData = await user.getUserFields(req.uid, ['username', 'email']);- data.username = allowLoginWith === 'email' ? userData.email : userData.username;+ const userData = await user.getUserFields(req.uid, ['username']);+ data.username = userData.username;data.alternate_logins = false;}res.render('login', data);diff --git a/src/upgrades/1.19.0/reenable-username-login.js b/src/upgrades/1.19.0/reenable-username-login.jsnew file mode 100644index 0000000000..197b4730cd--- /dev/null+++ b/src/upgrades/1.19.0/reenable-username-login.js@@ -0,0 +1,16 @@+'use strict';++const db = require('../../database');+const meta = require('../../meta');++module.exports = {+ name: 'Re-enable username login',+ timestamp: Date.UTC(2021, 10, 23),+ method: async () => {+ const setting = await meta.config.allowLoginWith;++ if (setting === 'email') {+ await meta.configs.set('allowLoginWith', 'username-email');+ }+ },+};diff --git a/src/views/admin/settings/user.tpl b/src/views/admin/settings/user.tplindex bc879b9d4c..d49788c68b 100644--- a/src/views/admin/settings/user.tpl+++ b/src/views/admin/settings/user.tpl@@ -16,7 +16,6 @@<select id="allowLoginWith" class="form-control" data-field="allowLoginWith"><option value="username-email">[[admin/settings/user:allow-login-with.username-email]]</option><option value="username">[[admin/settings/user:allow-login-with.username]]</option>- <option value="email">[[admin/settings/user:allow-login-with.email]]</option></select></div></form>