fix: guest join doesn't add avatar when logged in
All checks were successful
Build & Push Docker Image / build (push) Successful in 4m27s
All checks were successful
Build & Push Docker Image / build (push) Successful in 4m27s
This commit is contained in:
@@ -602,7 +602,7 @@ router.get('/:uid/public', async (req, res) => {
|
||||
// POST /api/rooms/:uid/guest-join - Join meeting as guest (no auth needed)
|
||||
router.post('/:uid/guest-join', guestJoinLimiter, async (req, res) => {
|
||||
try {
|
||||
const { name, access_code, moderator_code } = req.body;
|
||||
const { name, access_code, moderator_code, avatar_image, avatar_color } = req.body;
|
||||
|
||||
if (!name || name.trim().length === 0) {
|
||||
return res.status(400).json({ error: 'Name is required' });
|
||||
@@ -648,7 +648,17 @@ router.post('/:uid/guest-join', guestJoinLimiter, async (req, res) => {
|
||||
}
|
||||
|
||||
const baseUrl = getBaseUrl(req);
|
||||
const guestAvatarURL = `${baseUrl}/api/auth/avatar/initials/${encodeURIComponent(name.trim())}`;
|
||||
let guestAvatarURL;
|
||||
if (avatar_image) {
|
||||
// Use avatar image of the logged-in user
|
||||
guestAvatarURL = `${baseUrl}/api/auth/avatar/${avatar_image}`;
|
||||
} else if (avatar_color) {
|
||||
// Initials with user color
|
||||
guestAvatarURL = `${baseUrl}/api/auth/avatar/initials/${encodeURIComponent(name.trim())}?color=${encodeURIComponent(avatar_color)}`;
|
||||
} else {
|
||||
// Default: initials without color
|
||||
guestAvatarURL = `${baseUrl}/api/auth/avatar/initials/${encodeURIComponent(name.trim())}`;
|
||||
}
|
||||
const joinUrl = await joinMeeting(room.uid, name.trim(), isModerator, guestAvatarURL);
|
||||
res.json({ joinUrl });
|
||||
} catch (err) {
|
||||
|
||||
@@ -30,11 +30,17 @@ export default function GuestJoin() {
|
||||
const joinMeeting = async () => {
|
||||
setJoining(true);
|
||||
try {
|
||||
const res = await api.post(`/rooms/${uid}/guest-join`, {
|
||||
const payload = {
|
||||
name: name.trim(),
|
||||
access_code: accessCode || undefined,
|
||||
moderator_code: moderatorCode || undefined,
|
||||
});
|
||||
};
|
||||
// If logged in, send avatar data
|
||||
if (isLoggedIn && user) {
|
||||
if (user.avatar_image) payload.avatar_image = user.avatar_image;
|
||||
if (user.avatar_color) payload.avatar_color = user.avatar_color;
|
||||
}
|
||||
const res = await api.post(`/rooms/${uid}/guest-join`, payload);
|
||||
if (res.data.joinUrl) {
|
||||
window.location.href = res.data.joinUrl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user