1
0
Fork 0

fix(backend): Fix eslint-flagged errors

This commit is contained in:
Benjamin F 2022-12-29 15:51:21 -08:00
parent 72a99cc646
commit 85628caad1
4 changed files with 10 additions and 11 deletions

View file

@ -1,6 +1,6 @@
import { log } from '../utils/log.mjs' import { log } from '../utils/log.mjs'
import { hash, hashPassword, randomString, verifyPassword } from '../utils/crypto.mjs' import { hashPassword, randomString, verifyPassword } from '../utils/crypto.mjs'
import { clean, asJson } from '../utils/index.mjs' import { asJson } from '../utils/index.mjs'
import { UserModel } from './user.mjs' import { UserModel } from './user.mjs'
export function ApikeyModel(tools) { export function ApikeyModel(tools) {

View file

@ -247,7 +247,7 @@ PatternModel.prototype.unguardedDelete = async function () {
/* /*
* Removes the pattern - Checks permissions * Removes the pattern - Checks permissions
*/ */
PatternModel.prototype.guardedDelete = async function ({ params, body, user }) { PatternModel.prototype.guardedDelete = async function ({ params, user }) {
if (user.level < 3) return this.setResponse(403, 'insufficientAccessLevel') if (user.level < 3) return this.setResponse(403, 'insufficientAccessLevel')
if (user.iss && user.status < 1) return this.setResponse(403, 'accountStatusLacking') if (user.iss && user.status < 1) return this.setResponse(403, 'accountStatusLacking')

View file

@ -39,7 +39,7 @@ UserModel.prototype.read = async function (where) {
/* /*
* Helper method to decrypt at-rest data * Helper method to decrypt at-rest data
*/ */
UserModel.prototype.reveal = async function (where) { UserModel.prototype.reveal = async function () {
this.clear = {} this.clear = {}
if (this.record) { if (this.record) {
for (const field of this.encryptedFields) { for (const field of this.encryptedFields) {
@ -274,12 +274,12 @@ UserModel.prototype.confirm = async function ({ body, params }) {
await this.Confirmation.read({ id: params.id }) await this.Confirmation.read({ id: params.id })
if (!this.Confirmation.exists) { if (!this.Confirmation.exists) {
log.warn(err, `Could not find confirmation id ${params.id}`) log.warn(`Could not find confirmation id ${params.id}`)
return this.setResponse(404) return this.setResponse(404)
} }
if (this.Confirmation.record.type !== 'signup') { if (this.Confirmation.record.type !== 'signup') {
log.warn(err, `Confirmation mismatch; ${params.id} is not a signup id`) log.warn(`Confirmation mismatch; ${params.id} is not a signup id`)
return this.setResponse(404) return this.setResponse(404)
} }
@ -356,7 +356,6 @@ UserModel.prototype.guardedUpdate = async function ({ body, user }) {
data.lusername = clean(body.username) data.lusername = clean(body.username)
} else { } else {
log.info(`Rejected user name change from ${data.username} to ${body.username.trim()}`) log.info(`Rejected user name change from ${data.username} to ${body.username.trim()}`)
notes.push('usernameChangeRejected')
} }
} }
// Image (img) // Image (img)
@ -401,12 +400,12 @@ UserModel.prototype.guardedUpdate = async function ({ body, user }) {
await this.Confirmation.read({ id: body.confirmation }) await this.Confirmation.read({ id: body.confirmation })
if (!this.Confirmation.exists) { if (!this.Confirmation.exists) {
log.warn(err, `Could not find confirmation id ${params.id}`) log.warn(`Could not find confirmation id ${body.confirmation}`)
return this.setResponse(404) return this.setResponse(404)
} }
if (this.Confirmation.record.type !== 'emailchange') { if (this.Confirmation.record.type !== 'emailchange') {
log.warn(err, `Confirmation mismatch; ${params.id} is not an emailchange id`) log.warn(`Confirmation mismatch; ${body.confirmation} is not an emailchange id`)
return this.setResponse(404) return this.setResponse(404)
} }
@ -630,7 +629,7 @@ UserModel.prototype.isLusernameAvailable = async function (lusername) {
try { try {
await this.prisma.user.findUnique({ where: { lusername } }) await this.prisma.user.findUnique({ where: { lusername } })
} catch (err) { } catch (err) {
log.warn({ err, where }, 'Could not search for free username') log.warn({ err, lusername }, 'Could not search for free username')
} }
return true return true

View file

@ -122,6 +122,6 @@ export const setup = async () => {
return { chai, config, expect, store } return { chai, config, expect, store }
} }
export const teardown = async function (store) { export const teardown = async function (/*store*/) {
//console.log(store) //console.log(store)
} }