Skip to content

Commit

Permalink
✨ v0.7.4-rc1 (#3099)
Browse files Browse the repository at this point in the history
* fix(openIdStrategy): return user object on new user creation

* ✨ v0.7.4-rc1
  • Loading branch information
danny-avila authored Jun 17, 2024
1 parent dad25bd commit 302b28f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
6 changes: 5 additions & 1 deletion api/models/userMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ const updateUser = async function (userId, updateData) {
* 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 {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.
* @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 = {
...data,
expiresAt: disableTTL ? null : new Date(Date.now() + 604800 * 1000), // 1 week in milliseconds
Expand All @@ -71,6 +72,9 @@ const createUser = async (data, disableTTL = true) => {

try {
const user = await User.create(userData);
if (returnUser) {
return user.toObject();
}
return user._id;
} catch (error) {
if (error.code === 11000) {
Expand Down
3 changes: 1 addition & 2 deletions api/strategies/openidStrategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ async function setupOpenId() {
emailVerified: userinfo.email_verified || false,
name: fullName,
};
const userId = await createUser();
user._id = userId;
user = await createUser(user, true, true);
} else {
user.provider = 'openid';
user.openidId = userinfo.sub;
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "LibreChat",
"version": "0.7.3",
"version": "0.7.4-rc1",
"description": "",
"workspaces": [
"api",
Expand Down
2 changes: 1 addition & 1 deletion packages/data-provider/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "librechat-data-provider",
"version": "0.6.7",
"version": "0.6.8",
"description": "data services for librechat apps",
"main": "dist/index.js",
"module": "dist/index.es.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/data-provider/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ export enum SettingsTabValues {
/** Enum for app-wide constants */
export enum Constants {
/** Key for the app's version. */
VERSION = 'v0.7.3',
VERSION = 'v0.7.4-rc1',
/** Key for the Custom Config's version (librechat.yaml). */
CONFIG_VERSION = '1.1.4',
/** Standard value for the first message's `parentMessageId` value, to indicate no parent exists. */
Expand Down

0 comments on commit 302b28f

Please sign in to comment.