diff --git a/sites/backend/src/models/apikey.mjs b/sites/backend/src/models/apikey.mjs index 1983c57afe8..c81199e0c63 100644 --- a/sites/backend/src/models/apikey.mjs +++ b/sites/backend/src/models/apikey.mjs @@ -42,7 +42,8 @@ ApikeyModel.prototype.sendResponse = async function (res) { ApikeyModel.prototype.verify = async function (key, secret) { await this.unguardedRead({ id: key }) - const [valid] = await verifyPassword(secret, this.record.secret) + const verify = await verifyPassword(secret, this.record.secret) + const [valid] = verify this.verified = valid return this diff --git a/sites/backend/src/models/set.mjs b/sites/backend/src/models/set.mjs index 211e8bf0256..e79813f871d 100644 --- a/sites/backend/src/models/set.mjs +++ b/sites/backend/src/models/set.mjs @@ -313,7 +313,7 @@ SetModel.prototype.userSets = async function (uid) { log.warn(`Failed to search sets for user ${uid}: ${err}`) } const list = [] - for (const set of sets) list.push(await this.revealSet(set)) + for (const set of sets) list.push(this.revealSet(set)) return list } diff --git a/sites/backend/src/utils/crypto.mjs b/sites/backend/src/utils/crypto.mjs index 21486765bd0..55cadd19109 100644 --- a/sites/backend/src/utils/crypto.mjs +++ b/sites/backend/src/utils/crypto.mjs @@ -53,7 +53,8 @@ export function encryption(stringKey, salt = 'FreeSewing') { try { data = asJson(data) } catch (err) { - throw ('Could not parse input to encrypt() call', err) + console.log(err) + throw 'Could not parse input to encrypt() call' } /* @@ -84,7 +85,8 @@ export function encryption(stringKey, salt = 'FreeSewing') { try { data = JSON.parse(data) } catch (err) { - throw ('Could not parse encrypted data in decrypt() call', err) + console.log(err) + throw 'Could not parse encrypted data in decrypt() call' } if (!data.iv || typeof data.ct === 'undefined') { throw 'Encrypted data passed to decrypt() was malformed' diff --git a/sites/backend/src/utils/sanity.mjs b/sites/backend/src/utils/sanity.mjs index bc531373750..104c42fff75 100644 --- a/sites/backend/src/utils/sanity.mjs +++ b/sites/backend/src/utils/sanity.mjs @@ -37,7 +37,7 @@ export const setPatternAvatar = async (id, data) => setAvatar('pattern', id, dat export async function setAvatar(type, id, data) { // Step 1: Upload the image as asset const [contentType, binary] = b64ToBinaryWithType(data) - if (contentType && binary) { + if (contentType) { const img = await axios.post(`${config.api}/assets/images/${config.dataset}`, binary, { headers: { ...headers, diff --git a/sites/backend/tests/index.mjs b/sites/backend/tests/index.mjs index a85cca5f368..a2e3f1bff98 100644 --- a/sites/backend/tests/index.mjs +++ b/sites/backend/tests/index.mjs @@ -8,13 +8,13 @@ import { patternTests } from './pattern.mjs' import { setup } from './shared.mjs' const runTests = async (...params) => { - //await userTests(...params) - //await mfaTests(...params) - //await apikeyTests(...params) - //await accountTests(...params) - //await setTests(...params) + await userTests(...params) + await mfaTests(...params) + await apikeyTests(...params) + await accountTests(...params) + await setTests(...params) await curatedSetTests(...params) - //await patternTests(...params) + await patternTests(...params) } // Load initial data required for tests diff --git a/sites/shared/components/account/control.mjs b/sites/shared/components/account/control.mjs index 2f9ff4b3711..13bcdbda03f 100644 --- a/sites/shared/components/account/control.mjs +++ b/sites/shared/components/account/control.mjs @@ -15,7 +15,7 @@ export const ns = ['account', 'toast'] export const ControlSettings = ({ title = false, welcome = false }) => { // Context - const { loading, startLoading, stopLoading } = useContext(LoadingContext) + const { startLoading, stopLoading } = useContext(LoadingContext) // Hooks const { account, setAccount, token } = useAccount() diff --git a/sites/shared/components/account/sets.mjs b/sites/shared/components/account/sets.mjs index 084801c5b74..babe65ef29c 100644 --- a/sites/shared/components/account/sets.mjs +++ b/sites/shared/components/account/sets.mjs @@ -1,8 +1,6 @@ // Dependencies import { useState, useEffect, useContext, useCallback } from 'react' import { useTranslation } from 'next-i18next' -import { DateTime } from 'luxon' -import { CopyToClipboard } from 'react-copy-to-clipboard' import orderBy from 'lodash.orderby' import { measurements, isDegreeMeasurement } from 'config/measurements.mjs' import { measurementAsMm, formatMm } from 'shared/utils.mjs' @@ -30,10 +28,7 @@ import { PlusIcon, OkIcon, NoIcon, - DownIcon, - CopyIcon, TrashIcon, - LeftIcon, EditIcon, } from 'shared/components/icons.mjs' import { ModalWrapper } from 'shared/components/wrappers/modal.mjs' @@ -41,8 +36,6 @@ import Markdown from 'react-markdown' import { Tab } from './bio.mjs' import Timeago from 'react-timeago' import { Spinner } from 'shared/components/spinner.mjs' -import Link from 'next/link' -import { SaveSettingsButton } from 'shared/components/buttons/save-settings-button.mjs' export const ns = ['account', 'patterns', 'toast'] @@ -70,7 +63,7 @@ export const NewSet = ({ standalone = false, }) => { // Context - const { loading, startLoading, stopLoading } = useContext(LoadingContext) + const { startLoading, stopLoading } = useContext(LoadingContext) // Hooks const router = useRouter() @@ -97,11 +90,6 @@ export const NewSet = ({ stopLoading() } - // Helper method to clear inputs - const clear = () => { - setMset(false) - } - return (
FIXME: No edit component for this field
} -const noop = () => null - export const EditRow = (props) => (fixme
+ /* return ( {TODO
, -} - -const hasRequiredMeasurementsMethod = (design, gist) => { - if (design.patternConfig?.measurements?.length > 0 && !gist.measurements) return false - - for (const m of design.patternConfig?.measurements || []) { - if (!gist.measurements[m]) return false - } - - return true -} - -const doPreload = async (preload, from, design, gist, setGist, setPreloaded) => { - const g = await preloaders[from](preload, design) - setPreloaded(preload) - setGist({ ...gist, ...g.settings }) -} - -/* - * This component wraps the workbench and is in charge of - * keeping the gist state, which will trickle down - * to all workbench subcomponents -export const WorkbenchWrapper = ({ - app, - design, - preload = false, - from = false, - layout = false, -}) => { - // State for gist - const { gist, setGist, unsetGist, updateGist, gistReady, undoGist, resetGist } = useGist( - design.designConfig?.data?.name, - app.locale - ) - const [messages, setMessages] = useState([]) - const [popup, setPopup] = useState(false) - const [preloaded, setPreloaded] = useState(false) - // we'll only use this if the renderer is svg, but we can't call hooks conditionally - const { t } = useTranslation(['plugin']) - - // We'll use this in more than one location - const hasRequiredMeasurements = hasRequiredMeasurementsMethod(design, gist) - - // If we don't have the required measurements, - // force view to measurements - useEffect(() => { - if (!gistReady) return - if (!['measurements', 'edit'].includes(gist._state?.view) && !hasRequiredMeasurements) - updateGist(['_state', 'view'], 'measurements') - }, [gistReady, gist._state?.view, hasRequiredMeasurements, updateGist]) - - // If we need to preload the gist, do so - useEffect(() => { - if (preload && preload !== preloaded && from && preloaders[from]) { - doPreload(preload, from, design, gist, setGist, setPreloaded) - } - }, [preload, preloaded, from, design, gist, setGist]) - - // Helper methods to manage the gist state - const updateWBGist = useMemo( - () => - (path, value, closeNav = false, addToHistory = true) => { - updateGist(path, value, addToHistory) - // Force close of menu on mobile if it is open - if (closeNav && app.primaryMenu) app.setPrimaryMenu(false) - }, - [app, updateGist] - ) - - // Helper methods to handle messages - const feedback = { - add: (msg) => { - const newMsgs = [...messages] - if (Array.isArray(msg)) newMsgs.push(...msg) - else newMsgs.push(msg) - setMessages(newMsgs) - }, - set: setMessages, - clear: () => setMessages([]), - } - - // don't do anything until the gist is ready - if (!gistReady) { - return null - } - - // Generate the draft here so we can pass it down to both the view and the options menu - let draft = false - if (['draft', 'logs', 'test', 'printingLayout'].indexOf(gist._state?.view) !== -1) { - gist.embed = true - // get the appropriate layout for the view - const layout = gist.layouts?.[gist._state.view] || gist.layout || true - // hand it separately to the design - draft = new design({ ...gist, layout }) - //draft.__init() - - // add theme to svg renderer - if (gist.renderer === 'svg') { - draft.use(pluginI18n, { t }) - draft.use(pluginTheme, { skipGrid: ['pages'] }) - } - - // draft it for draft and event views. Other views may add plugins, etc and we don't want to draft twice - try { - if (['draft', 'logs'].indexOf(gist._state.view) > -1) draft.draft() - } catch (error) { - return