refactor: switch to using slugify module

This commit is contained in:
Barış Soner Uşaklı
2020-10-11 21:49:37 -04:00
parent bddfcb5867
commit dc29f4dca2
28 changed files with 88 additions and 60 deletions

View File

@@ -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([