Enhance dashboard guild access with owner bypass functionality
- Introduced `resolveDashboardGuild` to handle guild resolution for both managed and owner-panel bypass scenarios. - Updated `GuildLayout` and `WelcomePage` components to utilize the new guild resolution logic, improving access handling. - Enhanced `DashboardShell` to display an informational banner for users accessing guilds via the owner-panel bypass. - Added localization support for owner bypass messages in English and German. - Updated authentication logic to allow owner-panel users to access guilds without Discord Manage Guild permission.
This commit is contained in:
@@ -2,7 +2,7 @@ import { notFound } from 'next/navigation';
|
||||
import type { ReactNode } from 'react';
|
||||
import { DashboardShell } from '@/components/layout/dashboard-shell';
|
||||
import { requireGuildAccessOrRedirect } from '@/lib/auth';
|
||||
import { getManageableGuilds } from '@/lib/guilds';
|
||||
import { getManageableGuilds, resolveDashboardGuild } from '@/lib/guilds';
|
||||
import { isOwnerUser } from '@/lib/owner-auth';
|
||||
|
||||
interface GuildLayoutProps {
|
||||
@@ -13,23 +13,26 @@ interface GuildLayoutProps {
|
||||
export default async function GuildLayout({ children, params }: GuildLayoutProps) {
|
||||
const { guildId } = await params;
|
||||
const session = await requireGuildAccessOrRedirect(guildId);
|
||||
const guilds = await getManageableGuilds(session);
|
||||
const currentGuild = guilds.find((guild) => guild.id === guildId);
|
||||
const [resolved, guilds, showOwnerLink] = await Promise.all([
|
||||
resolveDashboardGuild(session, guildId),
|
||||
getManageableGuilds(session),
|
||||
isOwnerUser(session.user.id)
|
||||
]);
|
||||
|
||||
if (!currentGuild) {
|
||||
if (!resolved) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
const otherGuilds = guilds.filter((guild) => guild.id !== guildId);
|
||||
const showOwnerLink = await isOwnerUser(session.user.id);
|
||||
|
||||
return (
|
||||
<DashboardShell
|
||||
guildId={guildId}
|
||||
currentGuild={currentGuild}
|
||||
currentGuild={resolved.guild}
|
||||
otherGuilds={otherGuilds}
|
||||
user={session.user}
|
||||
showOwnerLink={showOwnerLink}
|
||||
ownerBypass={resolved.ownerBypass}
|
||||
>
|
||||
{children}
|
||||
</DashboardShell>
|
||||
|
||||
Reference in New Issue
Block a user