mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-20 07:20:27 +01:00
refactor: switch to using slugify module
This commit is contained in:
@@ -13,6 +13,7 @@ const meta = require('../meta');
|
||||
const user = require('../user');
|
||||
const plugins = require('../plugins');
|
||||
const utils = require('../utils');
|
||||
const slugify = require('../slugify');
|
||||
const translator = require('../translator');
|
||||
const helpers = require('./helpers');
|
||||
const privileges = require('../privileges');
|
||||
@@ -81,7 +82,7 @@ authenticationController.register = async function (req, res) {
|
||||
throw new Error('[[error:invalid-email]]');
|
||||
}
|
||||
|
||||
if (!userData.username || userData.username.length < meta.config.minimumUsernameLength || utils.slugify(userData.username).length < meta.config.minimumUsernameLength) {
|
||||
if (!userData.username || userData.username.length < meta.config.minimumUsernameLength || slugify(userData.username).length < meta.config.minimumUsernameLength) {
|
||||
throw new Error('[[error:username-too-short]]');
|
||||
}
|
||||
|
||||
@@ -356,7 +357,7 @@ authenticationController.localLogin = async function (req, username, password, n
|
||||
return next(new Error('[[error:password-too-long]]'));
|
||||
}
|
||||
|
||||
const userslug = utils.slugify(username);
|
||||
const userslug = slugify(username);
|
||||
const uid = await user.getUidByUserslug(userslug);
|
||||
try {
|
||||
const [userData, isAdminOrGlobalMod, banned, hasLoginPrivilege] = await Promise.all([
|
||||
|
||||
Reference in New Issue
Block a user