mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01: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.
|
||||
* @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
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue