1
0
Fork 0

chore: linter issues

This commit is contained in:
joostdecock 2023-08-13 09:54:56 +02:00
parent d899e56c07
commit 0c17e82f8f
6 changed files with 18 additions and 27 deletions

View file

@ -572,7 +572,7 @@ const v2lut = {
* This is a special route not available for API users * This is a special route not available for API users
*/ */
PatternModel.prototype.import = async function (v2user, lut, userId) { PatternModel.prototype.import = async function (v2user, lut, userId) {
for (const [handle, pattern] of Object.entries(v2user.patterns)) { for (const pattern of Object.values(v2user.patterns)) {
let skip = false let skip = false
const data = { ...migratePattern(pattern, userId), userId } const data = { ...migratePattern(pattern, userId), userId }
if (lut[pattern.person]) data.setId = lut[pattern.person] if (lut[pattern.person]) data.setId = lut[pattern.person]

View file

@ -74,7 +74,7 @@ UserModel.prototype.find = async function (body) {
* Failed to run database query. Log warning and return 404 * Failed to run database query. Log warning and return 404
*/ */
log.warn({ err, body }, `Error while trying to find user: ${body.username}`) log.warn({ err, body }, `Error while trying to find user: ${body.username}`)
return setResponse(404) return this.setResponse(404)
} }
/* /*
@ -111,8 +111,8 @@ UserModel.prototype.loadAuthenticatedUser = async function (user) {
/* /*
* Failed to run database query. Log warning and return 404 * Failed to run database query. Log warning and return 404
*/ */
log.warn({ err, body }, `Error while trying to find user: ${user.uid}`) log.warn({ err, user }, `Error while trying to find user: ${user.uid}`)
return setResponse(404) return this.setResponse(404)
} }
return this return this
@ -144,8 +144,8 @@ UserModel.prototype.revealAuthenticatedUser = async function (user) {
/* /*
* Failed to run database query. Log warning and return 404 * Failed to run database query. Log warning and return 404
*/ */
log.warn({ err, body }, `Error while trying to find and reveal user: ${user.uid}`) log.warn({ err, user }, `Error while trying to find and reveal user: ${user.uid}`)
return setResponse(404) return this.setResponse(404)
} }
return this.reveal() return this.reveal()
@ -849,9 +849,9 @@ UserModel.prototype.guardedUpdate = async function ({ body, user }) {
}) })
} }
} else if ( } else if (
/* /*
* Could be an email change confirmation * Could be an email change confirmation
*/ */
typeof body.confirmation === 'string' && typeof body.confirmation === 'string' &&
body.confirm === 'emailchange' && body.confirm === 'emailchange' &&
typeof body.check === 'string' typeof body.check === 'string'
@ -1003,9 +1003,9 @@ UserModel.prototype.guardedMfaUpdate = async function ({ body, user, ip }) {
return this.setResponse(401, 'authenticationFailed') return this.setResponse(401, 'authenticationFailed')
} }
} else if (body.mfa === true && body.token && body.secret) { } else if (body.mfa === true && body.token && body.secret) {
/* /*
* Option 2/3: Is this is a confirmation after enabling MFA? * Option 2/3: Is this is a confirmation after enabling MFA?
*/ */
/* /*
* Verify secret and token * Verify secret and token
*/ */
@ -1035,9 +1035,9 @@ UserModel.prototype.guardedMfaUpdate = async function ({ body, user, ip }) {
* Secret and/or token don't match. Return 403 * Secret and/or token don't match. Return 403
*/ */
} else if (body.mfa === true && this.record.mfaEnabled === false) { } else if (body.mfa === true && this.record.mfaEnabled === false) {
/* /*
* Option 3/3: Is this an initial request to enable MFA? * Option 3/3: Is this an initial request to enable MFA?
*/ */
/* /*
* Setup MFA * Setup MFA
*/ */

View file

@ -70,7 +70,6 @@ export async function replaceImage(props, isTest = false) {
export async function ensureImage(props, isTest = false) { export async function ensureImage(props, isTest = false) {
if (isTest) return props.id || false if (isTest) return props.id || false
const form = getFormData(props) const form = getFormData(props)
let result
try { try {
await axios.post(config.api, form, { headers }) await axios.post(config.api, form, { headers })
} catch (err) { } catch (err) {

View file

@ -341,10 +341,10 @@ export function decorateModel(Model, tools, modelConfig) {
*/ */
Model.time = function (key) { Model.time = function (key) {
if (this.timer) if (this.timer)
log.info(`Timer split [${key ? key : modalConfig.name}] ${Date.now() - this.timer}ms`) log.info(`Timer split [${key ? key : modelConfig.name}] ${Date.now() - this.timer}ms`)
else { else {
this.timer = Date.now() this.timer = Date.now()
log.info(`Timer start [${key ? key : modalConfig.name}] 0ms`) log.info(`Timer start [${key ? key : modelConfig.name}] 0ms`)
} }
return this return this

View file

@ -89,7 +89,7 @@ const importUsers = async () => {
let total = 0 let total = 0
const batches = splitArray(todo, batchSize) const batches = splitArray(todo, batchSize)
for (const batch of batches) { for (const batch of batches) {
const result = await fetch(`${BACKEND}/import/users`, { await fetch(`${BACKEND}/import/users`, {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',

View file

@ -1,13 +1,5 @@
import users from '../dump/v2-users.json' assert { type: 'json' } import users from '../dump/v2-users.json' assert { type: 'json' }
const lastLoginInDays = (user) => {
if (!user.time?.login) return 1000
const now = new Date()
const then = new Date(user.time.login)
return Math.floor((now - then) / (1000 * 60 * 60 * 24))
}
const usersToNotImport = () => users.filter((user) => user.status !== 'active') const usersToNotImport = () => users.filter((user) => user.status !== 'active')
// Commented out for linter // Commented out for linter
//const usersToImport = () => //const usersToImport = () =>