mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
update profile picture (#792)
This commit is contained in:
parent
afd43afb60
commit
1dacfa49f0
3 changed files with 11 additions and 5 deletions
|
|
@ -17,11 +17,6 @@ const discordLogin = async () =>
|
|||
const email = profile.email;
|
||||
const discordId = profile.id;
|
||||
|
||||
const oldUser = await User.findOne({ email });
|
||||
if (oldUser) {
|
||||
return cb(null, oldUser);
|
||||
}
|
||||
|
||||
let avatarURL;
|
||||
if (profile.avatar) {
|
||||
const format = profile.avatar.startsWith('a_') ? 'gif' : 'png';
|
||||
|
|
@ -31,6 +26,13 @@ const discordLogin = async () =>
|
|||
avatarURL = `https://cdn.discordapp.com/embed/avatars/${defaultAvatarNum}.png`;
|
||||
}
|
||||
|
||||
const oldUser = await User.findOne({ email });
|
||||
if (oldUser) {
|
||||
oldUser.avatar = avatarURL;
|
||||
await oldUser.save();
|
||||
return cb(null, oldUser);
|
||||
}
|
||||
|
||||
const newUser = await User.create({
|
||||
provider: 'discord',
|
||||
discordId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue