mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 08:12:00 +02:00
✨ v0.7.4-rc1 (#3099)
* fix(openIdStrategy): return user object on new user creation
* ✨ v0.7.4-rc1
This commit is contained in:
parent
dad25bd297
commit
302b28fc9b
6 changed files with 10 additions and 7 deletions
|
@ -56,10 +56,11 @@ const updateUser = async function (userId, updateData) {
|
||||||
* Creates a new user, optionally with a TTL of 1 week.
|
* Creates a new user, optionally with a TTL of 1 week.
|
||||||
* @param {MongoUser} data - The user data to be created, must contain user_id.
|
* @param {MongoUser} data - The user data to be created, must contain user_id.
|
||||||
* @param {boolean} [disableTTL=true] - Whether to disable the TTL. Defaults to `true`.
|
* @param {boolean} [disableTTL=true] - Whether to disable the TTL. Defaults to `true`.
|
||||||
|
* @param {boolean} [returnUser=false] - Whether to disable the TTL. Defaults to `true`.
|
||||||
* @returns {Promise<ObjectId>} A promise that resolves to the created user document ID.
|
* @returns {Promise<ObjectId>} A promise that resolves to the created user document ID.
|
||||||
* @throws {Error} If a user with the same user_id already exists.
|
* @throws {Error} If a user with the same user_id already exists.
|
||||||
*/
|
*/
|
||||||
const createUser = async (data, disableTTL = true) => {
|
const createUser = async (data, disableTTL = true, returnUser = false) => {
|
||||||
const userData = {
|
const userData = {
|
||||||
...data,
|
...data,
|
||||||
expiresAt: disableTTL ? null : new Date(Date.now() + 604800 * 1000), // 1 week in milliseconds
|
expiresAt: disableTTL ? null : new Date(Date.now() + 604800 * 1000), // 1 week in milliseconds
|
||||||
|
@ -71,6 +72,9 @@ const createUser = async (data, disableTTL = true) => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const user = await User.create(userData);
|
const user = await User.create(userData);
|
||||||
|
if (returnUser) {
|
||||||
|
return user.toObject();
|
||||||
|
}
|
||||||
return user._id;
|
return user._id;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.code === 11000) {
|
if (error.code === 11000) {
|
||||||
|
|
|
@ -164,8 +164,7 @@ async function setupOpenId() {
|
||||||
emailVerified: userinfo.email_verified || false,
|
emailVerified: userinfo.email_verified || false,
|
||||||
name: fullName,
|
name: fullName,
|
||||||
};
|
};
|
||||||
const userId = await createUser();
|
user = await createUser(user, true, true);
|
||||||
user._id = userId;
|
|
||||||
} else {
|
} else {
|
||||||
user.provider = 'openid';
|
user.provider = 'openid';
|
||||||
user.openidId = userinfo.sub;
|
user.openidId = userinfo.sub;
|
||||||
|
|
2
package-lock.json
generated
2
package-lock.json
generated
|
@ -29325,7 +29325,7 @@
|
||||||
},
|
},
|
||||||
"packages/data-provider": {
|
"packages/data-provider": {
|
||||||
"name": "librechat-data-provider",
|
"name": "librechat-data-provider",
|
||||||
"version": "0.6.7",
|
"version": "0.6.8",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/js-yaml": "^4.0.9",
|
"@types/js-yaml": "^4.0.9",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "LibreChat",
|
"name": "LibreChat",
|
||||||
"version": "0.7.3",
|
"version": "0.7.4-rc1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"api",
|
"api",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "librechat-data-provider",
|
"name": "librechat-data-provider",
|
||||||
"version": "0.6.7",
|
"version": "0.6.8",
|
||||||
"description": "data services for librechat apps",
|
"description": "data services for librechat apps",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"module": "dist/index.es.js",
|
"module": "dist/index.es.js",
|
||||||
|
|
|
@ -786,7 +786,7 @@ export enum SettingsTabValues {
|
||||||
/** Enum for app-wide constants */
|
/** Enum for app-wide constants */
|
||||||
export enum Constants {
|
export enum Constants {
|
||||||
/** Key for the app's version. */
|
/** Key for the app's version. */
|
||||||
VERSION = 'v0.7.3',
|
VERSION = 'v0.7.4-rc1',
|
||||||
/** Key for the Custom Config's version (librechat.yaml). */
|
/** Key for the Custom Config's version (librechat.yaml). */
|
||||||
CONFIG_VERSION = '1.1.4',
|
CONFIG_VERSION = '1.1.4',
|
||||||
/** Standard value for the first message's `parentMessageId` value, to indicate no parent exists. */
|
/** Standard value for the first message's `parentMessageId` value, to indicate no parent exists. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue