Skip to content

Commit

Permalink
👤 fix: Avatar Check in User Auth (#1677)
Browse files Browse the repository at this point in the history
  • Loading branch information
ineiti authored Jan 30, 2024
1 parent f7f7f92 commit 35e611f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions api/strategies/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>}
Expand All @@ -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;
Expand Down

0 comments on commit 35e611f

Please sign in to comment.