WIP! A BB-style forum, on the ATmosphere! We're still working... we'll be back soon when we have something to show off!
node typescript hono htmx atproto
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(web): add hasAnyAdminPermission() helper to session.ts (ATB-42)

Malpercio bf2c1fd1 4b0cc5b2

+21
+21
apps/web/src/lib/session.ts
··· 147 147 auth.permissions.has("*")) 148 148 ); 149 149 } 150 + 151 + /** Permission strings that constitute "any admin access". */ 152 + const ADMIN_PERMISSIONS = [ 153 + "space.atbb.permission.manageMembers", 154 + "space.atbb.permission.manageCategories", 155 + "space.atbb.permission.moderatePosts", 156 + "space.atbb.permission.banUsers", 157 + "space.atbb.permission.lockTopics", 158 + ] as const; 159 + 160 + /** 161 + * Returns true if the session grants at least one admin or mod permission, 162 + * or the wildcard "*". Used to gate the /admin landing page. 163 + */ 164 + export function hasAnyAdminPermission( 165 + auth: WebSessionWithPermissions 166 + ): boolean { 167 + if (!auth.authenticated) return false; 168 + if (auth.permissions.has("*")) return true; 169 + return ADMIN_PERMISSIONS.some((p) => auth.permissions.has(p)); 170 + }