From 04502e9525020e93a4e49afc55b93aec23f342bf Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Sat, 15 Jun 2024 10:36:49 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=A4=20fix:=20Create=20User=20with=20ti?= =?UTF-8?q?mestamps=20(#3070)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 👤 fix: Create User with timestamps * chore: fix lint script to ignore venv * chore: linting --- api/models/userMethods.js | 6 +++--- api/strategies/openidStrategy.js | 10 +++++----- client/src/components/Chat/Footer.tsx | 1 - package.json | 6 +++--- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/api/models/userMethods.js b/api/models/userMethods.js index 08d98045f5c..279672b926d 100644 --- a/api/models/userMethods.js +++ b/api/models/userMethods.js @@ -62,7 +62,7 @@ const updateUser = async function (userId, updateData) { const createUser = async (data, disableTTL = true) => { const userData = { ...data, - expiresAt: new Date(Date.now() + 604800 * 1000), // 1 week in milliseconds + expiresAt: disableTTL ? null : new Date(Date.now() + 604800 * 1000), // 1 week in milliseconds }; if (disableTTL) { @@ -70,8 +70,8 @@ const createUser = async (data, disableTTL = true) => { } try { - const result = await User.collection.insertOne(userData); - return result.insertedId; + const user = await User.create(userData); + return user._id; } catch (error) { if (error.code === 11000) { // Duplicate key error code diff --git a/api/strategies/openidStrategy.js b/api/strategies/openidStrategy.js index 30762898a6c..7fb108a4000 100644 --- a/api/strategies/openidStrategy.js +++ b/api/strategies/openidStrategy.js @@ -69,11 +69,11 @@ function convertToUsername(input, defaultValue = '') { async function setupOpenId() { try { if (process.env.PROXY) { - const proxyAgent = new HttpsProxyAgent(process.env.PROXY); - custom.setHttpOptionsDefaults({ - agent: proxyAgent - }); - logger.info(`[openidStrategy] proxy agent added: ${process.env.PROXY}`); + const proxyAgent = new HttpsProxyAgent(process.env.PROXY); + custom.setHttpOptionsDefaults({ + agent: proxyAgent, + }); + logger.info(`[openidStrategy] proxy agent added: ${process.env.PROXY}`); } const issuer = await Issuer.discover(process.env.OPENID_ISSUER); const client = new issuer.Client({ diff --git a/client/src/components/Chat/Footer.tsx b/client/src/components/Chat/Footer.tsx index 8e534d22d05..d0ac332ee69 100644 --- a/client/src/components/Chat/Footer.tsx +++ b/client/src/components/Chat/Footer.tsx @@ -5,7 +5,6 @@ import { Constants } from 'librechat-data-provider'; import { useGetStartupConfig } from 'librechat-data-provider/react-query'; import { useLocalize } from '~/hooks'; - export default function Footer({ className }: { className?: string }) { const { data: config } = useGetStartupConfig(); const localize = useLocalize(); diff --git a/package.json b/package.json index a707d74f3da..fb7ad3b5704 100644 --- a/package.json +++ b/package.json @@ -46,9 +46,9 @@ "e2e:update": "playwright test --config=e2e/playwright.config.js --update-snapshots", "e2e:report": "npx playwright show-report e2e/playwright-report", "prepare": "node config/prepare.js", - "lint:fix": "eslint --fix \"{,!(node_modules)/**/}*.{js,jsx,ts,tsx}\"", - "lint": "eslint \"{,!(node_modules)/**/}*.{js,jsx,ts,tsx}\"", - "format": "prettier-eslint --write \"{,!(node_modules)/**/}*.{js,jsx,ts,tsx}\"", + "lint:fix": "eslint --fix \"{,!(node_modules|venv)/**/}*.{js,jsx,ts,tsx}\"", + "lint": "eslint \"{,!(node_modules|venv)/**/}*.{js,jsx,ts,tsx}\"", + "format": "prettier-eslint --write \"{,!(node_modules|venv)/**/}*.{js,jsx,ts,tsx}\"", "b:api": "NODE_ENV=production bun run api/server/index.js", "b:api-inspect": "NODE_ENV=production bun --inspect run api/server/index.js", "b:api:dev": "NODE_ENV=production bun run --watch api/server/index.js",