mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 01:10:14 +01:00
👤 fix: Avatar Check in User Auth (#1677)
This commit is contained in:
parent
f7f7f929a0
commit
35e611f113
1 changed files with 3 additions and 3 deletions
|
|
@ -7,7 +7,7 @@ const User = require('~/models/User');
|
|||
* '?manual=true', it updates the user's avatar with the provided URL. For local file storage, it directly updates
|
||||
* the avatar URL, while for other storage types, it processes the avatar URL using the specified file strategy.
|
||||
*
|
||||
* @param {User} oldUser - The existing user object that needs to be updated. Expected to have an 'avatar' property.
|
||||
* @param {User} oldUser - The existing user object that needs to be updated.
|
||||
* @param {string} avatarUrl - The new avatar URL to be set for the user.
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
|
|
@ -19,10 +19,10 @@ const handleExistingUser = async (oldUser, avatarUrl) => {
|
|||
const fileStrategy = process.env.CDN_PROVIDER;
|
||||
const isLocal = fileStrategy === FileSources.local;
|
||||
|
||||
if (isLocal && !oldUser.avatar.includes('?manual=true')) {
|
||||
if (isLocal && (oldUser.avatar === null || !oldUser.avatar.includes('?manual=true'))) {
|
||||
oldUser.avatar = avatarUrl;
|
||||
await oldUser.save();
|
||||
} else if (!isLocal && !oldUser.avatar.includes('?manual=true')) {
|
||||
} else if (!isLocal && (oldUser.avatar === null || !oldUser.avatar.includes('?manual=true'))) {
|
||||
const userId = oldUser._id;
|
||||
const newavatarUrl = await uploadAvatar({ userId, input: avatarUrl, fileStrategy });
|
||||
oldUser.avatar = newavatarUrl;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue