start upgrading eslint

This commit is contained in:
Matteo Pagliazzi
2019-10-08 16:57:10 +02:00
parent 90c917f69e
commit 621787915c
304 changed files with 5992 additions and 6394 deletions

View File

@@ -3,7 +3,7 @@ import {
} from '../../middlewares/auth';
import * as authLib from '../../libs/auth';
import { model as User } from '../../models/user';
import {verifyUsername} from '../../libs/user/validation';
import { verifyUsername } from '../../libs/user/validation';
const api = {};
@@ -16,14 +16,14 @@ api.verifyUsername = {
async handler (req, res) {
req.checkBody({
username: {
notEmpty: {errorMessage: res.t('missingUsername')},
notEmpty: { errorMessage: res.t('missingUsername') },
},
});
const validationErrors = req.validationErrors();
if (validationErrors) throw validationErrors;
const user = res.locals.user;
const { user } = res.locals;
const chosenUsername = req.body.username;
const issues = verifyUsername(chosenUsername, res);
@@ -31,10 +31,10 @@ api.verifyUsername = {
if (issues.length < 1) {
const existingUser = await User.findOne({
'auth.local.lowerCaseUsername': chosenUsername.toLowerCase(),
}, {auth: 1}).exec();
}, { auth: 1 }).exec();
if (existingUser) {
if (!user || existingUser._id !== user._id) issues.push(res.t('usernameTaken'));
if (!user || existingUser._id !== user._id) issues.push(res.t('usernameTaken'));
}
}