Add automatic SSL certificate generation
All checks were successful
Build and Push / build-all (push) Successful in 1m36s
All checks were successful
Build and Push / build-all (push) Successful in 1m36s
This commit is contained in:
parent
42855330c0
commit
c20a5e7486
1 changed files with 32 additions and 25 deletions
|
|
@ -103,30 +103,30 @@ class ChatWebSocket {
|
||||||
handleMessage(data) {
|
handleMessage(data) {
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case 'welcome':
|
case 'welcome':
|
||||||
// If we have a token, we're about to authenticate - don't set guest info
|
// Always set initial user info from welcome message
|
||||||
// The auth_success message will set the correct user info
|
// If auth succeeds, auth_success will upgrade to authenticated user
|
||||||
if (!this.token) {
|
// This ensures proper fallback if auth fails (e.g., expired token)
|
||||||
chatUserInfo.set({
|
chatUserInfo.set({
|
||||||
username: data.username,
|
username: data.username,
|
||||||
userId: data.userId,
|
userId: data.userId,
|
||||||
isGuest: data.isGuest,
|
isGuest: data.isGuest,
|
||||||
isModerator: data.isModerator,
|
isModerator: data.isModerator,
|
||||||
isSiteModerator: data.isSiteModerator || false,
|
isSiteModerator: data.isSiteModerator || false,
|
||||||
isStreamer: data.isStreamer || false,
|
isStreamer: data.isStreamer || false,
|
||||||
isAdmin: data.isAdmin || false,
|
isAdmin: data.isAdmin || false,
|
||||||
avatarUrl: data.avatarUrl || ''
|
avatarUrl: data.avatarUrl || '',
|
||||||
});
|
userColor: data.userColor || '#888888'
|
||||||
|
});
|
||||||
|
|
||||||
// If guest and has saved name in localStorage, rename immediately
|
// If guest and has saved name in localStorage, rename immediately
|
||||||
if (data.isGuest && typeof localStorage !== 'undefined') {
|
if (data.isGuest && typeof localStorage !== 'undefined') {
|
||||||
const savedGuestName = localStorage.getItem('guestName');
|
const savedGuestName = localStorage.getItem('guestName');
|
||||||
if (savedGuestName && savedGuestName !== data.username) {
|
if (savedGuestName && savedGuestName !== data.username) {
|
||||||
console.log('Restoring saved guest name:', savedGuestName);
|
console.log('Restoring saved guest name:', savedGuestName);
|
||||||
// Delay slightly to ensure connection is fully established
|
// Delay slightly to ensure connection is fully established
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.sendRename(savedGuestName);
|
this.sendRename(savedGuestName);
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -175,9 +175,16 @@ class ChatWebSocket {
|
||||||
|
|
||||||
case 'error':
|
case 'error':
|
||||||
console.error('Chat error:', data.error);
|
console.error('Chat error:', data.error);
|
||||||
// Show error to user
|
// Show error to user for actionable errors (not auth errors which are handled separately)
|
||||||
if (data.error && typeof window !== 'undefined') {
|
if (data.error && typeof window !== 'undefined') {
|
||||||
alert(data.error);
|
const errorMsg = data.error.toLowerCase();
|
||||||
|
// Don't alert for auth/token errors - user should re-login
|
||||||
|
const isAuthError = errorMsg.includes('token') ||
|
||||||
|
errorMsg.includes('unauthorized') ||
|
||||||
|
errorMsg.includes('auth');
|
||||||
|
if (!isAuthError) {
|
||||||
|
alert(data.error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue