mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +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.",
|
"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",
|
"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?",
|
"remember_me": "Remember Me?",
|
||||||
"forgot_password": "Forgot Password?",
|
"forgot_password": "Forgot Password?",
|
||||||
"alternative_logins": "Alternative Logins",
|
"alternative_logins": "Alternative Logins",
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ Controllers.login = function(req, res, next) {
|
|||||||
data.showResetLink = emailersPresent;
|
data.showResetLink = emailersPresent;
|
||||||
data.allowLocalLogin = parseInt(meta.config.allowLocalLogin, 10) === 1;
|
data.allowLocalLogin = parseInt(meta.config.allowLocalLogin, 10) === 1;
|
||||||
data.allowRegistration = parseInt(meta.config.allowRegistration, 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.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[global:login]]'}]);
|
||||||
data.error = req.flash('error')[0];
|
data.error = req.flash('error')[0];
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,12 @@
|
|||||||
var passport = require('passport'),
|
var passport = require('passport'),
|
||||||
passportLocal = require('passport-local').Strategy,
|
passportLocal = require('passport-local').Strategy,
|
||||||
nconf = require('nconf'),
|
nconf = require('nconf'),
|
||||||
Password = require('../password'),
|
|
||||||
winston = require('winston'),
|
winston = require('winston'),
|
||||||
async = require('async'),
|
async = require('async'),
|
||||||
|
validator = require('validator'),
|
||||||
express = require('express'),
|
express = require('express'),
|
||||||
|
|
||||||
|
Password = require('../password'),
|
||||||
meta = require('../meta'),
|
meta = require('../meta'),
|
||||||
user = require('../user'),
|
user = require('../user'),
|
||||||
plugins = require('../plugins'),
|
plugins = require('../plugins'),
|
||||||
@@ -131,7 +132,9 @@
|
|||||||
req.session.returnTo = req.body.returnTo;
|
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) {
|
user.getUsernameByEmail(req.body.username, function(err, username) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
@@ -139,8 +142,10 @@
|
|||||||
req.body.username = username ? username : req.body.username;
|
req.body.username = username ? username : req.body.username;
|
||||||
continueLogin(req, res, next);
|
continueLogin(req, res, next);
|
||||||
});
|
});
|
||||||
} else {
|
} else if (loginWith.indexOf('username') !== -1 && !validator.isEmail(req.body.username)) {
|
||||||
continueLogin(req, res, next);
|
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>
|
<input type="checkbox" data-field="requireEmailConfirmation"> <strong>Require Email Confirmation</strong>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</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>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user