File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ "use client" ;
2+
3+ /**
4+ * 个人主页的"开发者选项"入口块。
5+ *
6+ * 和 AdminLinkIfOwnerAdmin 的区别——这里**不限 admin**,只要是主页 owner(当前登录
7+ * 用户 === 这个主页本人)就看得见。理由:
8+ * - 密钥管理 (Infisical) 是每个开发者都要用的,不是管理员专属。
9+ * Infisical 自己按 project / environment 做权限细分,进去后看不到自己没权限的 secrets。
10+ * - 以后其他"个人开发者工具"(比如 CI tokens、个人 API key 管理)也可以挂在这里
11+ *
12+ * 渲染条件:
13+ * 1. 已登录
14+ * 2. 当前登录用户就是这个主页的 owner(路人看不到)
15+ *
16+ * 注意:单独加 Link 而不是走 AdminGuard 风格,因为这是"入口按钮"不是"整页权限",
17+ * 二次校验由目标服务(Infisical)自己做。
18+ */
19+
20+ import Link from "next/link" ;
21+ import { useAuth } from "@/lib/use-auth" ;
22+
23+ interface Props {
24+ ownerGithubId : number | null ;
25+ ownerUsername : string ;
26+ }
27+
28+ export function DeveloperToolsIfOwner ( { ownerGithubId, ownerUsername } : Props ) {
29+ const { user, status } = useAuth ( ) ;
30+ if ( status !== "authenticated" || ! user ) return null ;
31+
32+ const isOwner =
33+ ( ownerGithubId != null && user . githubId === ownerGithubId ) ||
34+ user . username === ownerUsername ;
35+ if ( ! isOwner ) return null ;
36+
37+ return (
38+ < Link
39+ href = "https://secrets.involutionhell.com"
40+ target = "_blank"
41+ rel = "noopener noreferrer"
42+ className = "font-mono text-[11px] uppercase tracking-widest px-2 py-1 border border-[var(--foreground)] text-[var(--foreground)] hover:bg-[var(--foreground)] hover:text-[var(--background)] transition-colors font-bold"
43+ data-umami-event = "profile_devtools_secrets_click"
44+ title = "Infisical 密钥管理(GitHub OAuth 登录,按 project 权限查看)"
45+ >
46+ 密钥管理 ↗
47+ </ Link >
48+ ) ;
49+ }
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import { Footer } from "@/app/components/Footer";
88import { ProfileCard } from "./ProfileCard" ;
99import { EditLinkIfOwner } from "./EditLinkIfOwner" ;
1010import { AdminLinkIfOwnerAdmin } from "./AdminLinkIfOwnerAdmin" ;
11+ import { DeveloperToolsIfOwner } from "./DeveloperToolsIfOwner" ;
1112import { ActivityHeatmap } from "./ActivityHeatmap" ;
1213import { FollowButton } from "./FollowButton" ;
1314import { GithubRepos , GithubReposSkeleton } from "./GithubRepos" ;
@@ -411,6 +412,12 @@ export default async function UserProfilePage({ params }: Param) {
411412 ownerUsername = { user . username }
412413 identifier = { username }
413414 />
415+ { /* 开发者工具入口(所有本人都看得见;权限由目标服务自己管):
416+ 目前只有 Infisical 密钥管理,未来可挂 CI token / API key 等 */ }
417+ < DeveloperToolsIfOwner
418+ ownerGithubId = { user . githubId ?? null }
419+ ownerUsername = { user . username }
420+ />
414421 { /* 管理员自见入口:只有 roles=admin 的本人访问自己主页时才渲染 */ }
415422 < AdminLinkIfOwnerAdmin
416423 ownerGithubId = { user . githubId ?? null }
You can’t perform that action at this time.
0 commit comments