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) {
|
||||
switch (data.type) {
|
||||
case 'welcome':
|
||||
// If we have a token, we're about to authenticate - don't set guest info
|
||||
// The auth_success message will set the correct user info
|
||||
if (!this.token) {
|
||||
chatUserInfo.set({
|
||||
username: data.username,
|
||||
userId: data.userId,
|
||||
isGuest: data.isGuest,
|
||||
isModerator: data.isModerator,
|
||||
isSiteModerator: data.isSiteModerator || false,
|
||||
isStreamer: data.isStreamer || false,
|
||||
isAdmin: data.isAdmin || false,
|
||||
avatarUrl: data.avatarUrl || ''
|
||||
});
|
||||
// Always set initial user info from welcome message
|
||||
// If auth succeeds, auth_success will upgrade to authenticated user
|
||||
// This ensures proper fallback if auth fails (e.g., expired token)
|
||||
chatUserInfo.set({
|
||||
username: data.username,
|
||||
userId: data.userId,
|
||||
isGuest: data.isGuest,
|
||||
isModerator: data.isModerator,
|
||||
isSiteModerator: data.isSiteModerator || false,
|
||||
isStreamer: data.isStreamer || false,
|
||||
isAdmin: data.isAdmin || false,
|
||||
avatarUrl: data.avatarUrl || '',
|
||||
userColor: data.userColor || '#888888'
|
||||
});
|
||||
|
||||
// If guest and has saved name in localStorage, rename immediately
|
||||
if (data.isGuest && typeof localStorage !== 'undefined') {
|
||||
const savedGuestName = localStorage.getItem('guestName');
|
||||
if (savedGuestName && savedGuestName !== data.username) {
|
||||
console.log('Restoring saved guest name:', savedGuestName);
|
||||
// Delay slightly to ensure connection is fully established
|
||||
setTimeout(() => {
|
||||
this.sendRename(savedGuestName);
|
||||
}, 100);
|
||||
}
|
||||
// If guest and has saved name in localStorage, rename immediately
|
||||
if (data.isGuest && typeof localStorage !== 'undefined') {
|
||||
const savedGuestName = localStorage.getItem('guestName');
|
||||
if (savedGuestName && savedGuestName !== data.username) {
|
||||
console.log('Restoring saved guest name:', savedGuestName);
|
||||
// Delay slightly to ensure connection is fully established
|
||||
setTimeout(() => {
|
||||
this.sendRename(savedGuestName);
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -175,9 +175,16 @@ class ChatWebSocket {
|
|||
|
||||
case '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') {
|
||||
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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue