Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Production deployment #458

Merged
merged 1 commit into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/src/app/(app)/_components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const Sidebar = async () => {
<div>
<Account />

<CmdKLoader className="mt-4 mx-auto" />
<CmdKLoader className="hidden lg:block mt-4 mx-auto" />

<nav className="p-4 border-neutral-800">
<ul>
Expand Down
5 changes: 3 additions & 2 deletions app/src/app/(app)/dashboard/_components/ProfileTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type Props = Readonly<{

export const ProfileTile = async ({ className }: Props) => {
const authentication = await authenticate();
if (!authentication) return null;

const name =
authentication.session.user.name || authentication.session.discordId;
Expand Down Expand Up @@ -49,9 +50,9 @@ export const ProfileTile = async ({ className }: Props) => {
</div>
) : null}

{entity && (
{authentication.session.entityId && (
<Link
href={`/spynet/entity/${entity.id}`}
href={`/spynet/entity/${authentication.session.entityId}`}
prefetch={false}
className="text-sinister-red-500 hover:text-sinister-red-300 flex gap-2 items-center"
>
Expand Down
23 changes: 23 additions & 0 deletions app/src/app/_components/CmdK.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useRouter } from "next/navigation";
import { useEffect, useState, type Dispatch, type SetStateAction } from "react";
import { FaCog, FaHome, FaLock, FaUsers } from "react-icons/fa";
import { MdWorkspaces } from "react-icons/md";
import { RiSpyFill } from "react-icons/ri";
import useAuthentication from "~/_lib/auth/useAuthentication";
import "./CmdK.css";

Expand Down Expand Up @@ -81,6 +82,28 @@ export const CmdK = ({ open, setOpen }: Props) => {
</Command.Group>
)}

{authentication.authorize([
{
resource: "citizen",
operation: "read",
},
]) && (
<Command.Group heading="Spynet">
<Command.Item
keywords={["Spynet"]}
onSelect={() => {
router.push(
`/spynet/entity/${authentication.session.entityId}`,
);
setOpen(false);
}}
>
<RiSpyFill />
Eigenes Profil öffnen
</Command.Item>
</Command.Group>
)}

{(authentication.authorize([
{
resource: "user",
Expand Down
4 changes: 3 additions & 1 deletion app/src/server/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ declare module "next-auth" {
} & DefaultSession["user"];
discordId: string;
givenPermissionSets: PermissionSet[];
entityId: string | null;
}

interface User {
Expand Down Expand Up @@ -154,7 +155,8 @@ export const authOptions: NextAuthOptions = {
emailVerified: user.emailVerified,
},
discordId: discordAccount!.providerAccountId,
givenPermissionSets: givenPermissionSets,
givenPermissionSets,
entityId: entity?.id,
};
},

Expand Down