feat: Security
This commit is contained in:
@@ -317,13 +317,22 @@ export class ChatRoomPage {
|
||||
throw new Error('Missing room, user, or endpoint when persisting channels');
|
||||
}
|
||||
|
||||
const authTokens = JSON.parse(localStorage.getItem('metoyou.authTokens') || '{}') as Record<string, { token: string; expiresAt: number }>;
|
||||
const normalizedApiUrl = apiBaseUrl.trim().replace(/\/+$/, '');
|
||||
const authEntry = authTokens[normalizedApiUrl];
|
||||
const authToken = authEntry && authEntry.expiresAt > Date.now() ? authEntry.token : null;
|
||||
|
||||
if (!authToken) {
|
||||
throw new Error('Missing session token for channel persistence');
|
||||
}
|
||||
|
||||
const response = await fetch(`${apiBaseUrl}/api/servers/${room.id}`, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${authToken}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
currentOwnerId: currentUser.id,
|
||||
channels: nextChannels
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user