feat: add access control to channels with various modes
- Introduced AccessMode enum to define channel access levels: Public, PasswordProtected, AccountRequired, and OwnerOnly. - Updated Channel and ProgrammingBlock entities to include access_mode and access_password_hash fields. - Enhanced create and update channel functionality to handle access mode and password. - Implemented access checks in channel routes based on the defined access modes. - Modified frontend components to support channel creation and editing with access control options. - Added ChannelPasswordModal for handling password input when accessing restricted channels. - Updated API calls to include channel and block passwords as needed. - Created database migrations to add access_mode and access_password_hash columns to channels table.
This commit is contained in:
@@ -152,24 +152,31 @@ export const api = {
|
||||
getActive: (channelId: string, token: string) =>
|
||||
request<ScheduleResponse>(`/channels/${channelId}/schedule`, { token }),
|
||||
|
||||
getCurrentBroadcast: (channelId: string, token: string) =>
|
||||
request<CurrentBroadcastResponse | null>(`/channels/${channelId}/now`, {
|
||||
getCurrentBroadcast: (channelId: string, token: string, channelPassword?: string) => {
|
||||
const headers: Record<string, string> = {};
|
||||
if (channelPassword) headers["X-Channel-Password"] = channelPassword;
|
||||
return request<CurrentBroadcastResponse | null>(`/channels/${channelId}/now`, {
|
||||
token,
|
||||
}),
|
||||
headers,
|
||||
});
|
||||
},
|
||||
|
||||
getEpg: (
|
||||
channelId: string,
|
||||
token: string,
|
||||
from?: string,
|
||||
until?: string,
|
||||
channelPassword?: string,
|
||||
) => {
|
||||
const params = new URLSearchParams();
|
||||
if (from) params.set("from", from);
|
||||
if (until) params.set("until", until);
|
||||
const qs = params.toString();
|
||||
const headers: Record<string, string> = {};
|
||||
if (channelPassword) headers["X-Channel-Password"] = channelPassword;
|
||||
return request<ScheduledSlotResponse[]>(
|
||||
`/channels/${channelId}/epg${qs ? `?${qs}` : ""}`,
|
||||
{ token },
|
||||
{ token, headers },
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user