Fix avatar infinite redirect (#5299)

* If due to some reason avatar URL is same as route, avoid infinite redirection by serving default

* Fix avatar reverting issue

Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: alannnc <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2022-11-01 06:30:08 +00:00
1 parent 77d339ae8f
commit b3ba89c074
2 files changed
+12 -2

No files matched your search

+2 -1
View File
@@ -88,7 +88,8 @@ async function getUserFromSession({
return null;
}
// This helps to prevent reaching the 4MB payload limit by avoiding base64 and instead passing the avatar url
if (user.avatar) user.avatar = `${CAL_URL}/${user.username}/avatar.png`;
// TODO: Setting avatar value to /avatar.png(which is a dynamic route) would actually reset the avatar because /avatar.png is supposed to return the value of user.avatar
// if (user.avatar) user.avatar = `${CAL_URL}/${user.username}/avatar.png`;
const avatar = user.avatar || defaultAvatarSrc({ email });
const locale = user.locale || getLocaleFromHeaders(req);