mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-04 06:40:44 +01:00
closes #2618
This commit is contained in:
@@ -96,5 +96,7 @@
|
||||
"reload-failed": "NodeBB encountered a problem while reloading: \"%1\". NodeBB will continue to serve the existing client-side assets, although you should undo what you did just prior to reloading.",
|
||||
|
||||
"registration-error": "Registration Error",
|
||||
"parse-error": "Something went wrong while parsing server response"
|
||||
"parse-error": "Something went wrong while parsing server response",
|
||||
"wrong-login-type-email": "Please use your email to login",
|
||||
"wrong-login-type-username": "Please use your username to login"
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
{
|
||||
"username": "Username / Email",
|
||||
"username-email": "Username / Email",
|
||||
"username": "Username",
|
||||
"email": "Email",
|
||||
"remember_me": "Remember Me?",
|
||||
"forgot_password": "Forgot Password?",
|
||||
"alternative_logins": "Alternative Logins",
|
||||
|
||||
@@ -70,6 +70,7 @@ Controllers.login = function(req, res, next) {
|
||||
data.showResetLink = emailersPresent;
|
||||
data.allowLocalLogin = parseInt(meta.config.allowLocalLogin, 10) === 1;
|
||||
data.allowRegistration = parseInt(meta.config.allowRegistration, 10) === 1;
|
||||
data.allowLoginWith = '[[login:' + (meta.config.allowLoginWith || 'username-email') + ']]';
|
||||
data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[global:login]]'}]);
|
||||
data.error = req.flash('error')[0];
|
||||
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
var passport = require('passport'),
|
||||
passportLocal = require('passport-local').Strategy,
|
||||
nconf = require('nconf'),
|
||||
Password = require('../password'),
|
||||
winston = require('winston'),
|
||||
async = require('async'),
|
||||
validator = require('validator'),
|
||||
express = require('express'),
|
||||
|
||||
Password = require('../password'),
|
||||
meta = require('../meta'),
|
||||
user = require('../user'),
|
||||
plugins = require('../plugins'),
|
||||
@@ -131,7 +132,9 @@
|
||||
req.session.returnTo = req.body.returnTo;
|
||||
}
|
||||
|
||||
if (req.body.username && utils.isEmailValid(req.body.username)) {
|
||||
var loginWith = meta.config.allowLoginWith || 'username-email';
|
||||
|
||||
if (req.body.username && utils.isEmailValid(req.body.username) && loginWith.indexOf('email') !== -1) {
|
||||
user.getUsernameByEmail(req.body.username, function(err, username) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
@@ -139,8 +142,10 @@
|
||||
req.body.username = username ? username : req.body.username;
|
||||
continueLogin(req, res, next);
|
||||
});
|
||||
} else {
|
||||
} else if (loginWith.indexOf('username') !== -1 && !validator.isEmail(req.body.username)) {
|
||||
continueLogin(req, res, next);
|
||||
} else {
|
||||
res.status(500).send('[[error:wrong-login-type-' + loginWith + ']]');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,15 @@
|
||||
<input type="checkbox" data-field="requireEmailConfirmation"> <strong>Require Email Confirmation</strong>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Allow login with</label>
|
||||
<select class="form-control" data-field="allowLoginWith">
|
||||
<option value="username-email">Username or Email</option>
|
||||
<option value="username">Username Only</option>
|
||||
<option value="email">Email Only</option>
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user