Show Secrets to superusers only, and guard its route as Admin is

The page reads GET /secrets/, which is a superuser's, so any other account
opened it onto a permission error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013GAeg4Jo6xjZzjwy9QDWMQ
This commit is contained in:
2026-10-06 12:33:00 +02:00
co-authored by Claude Opus 5.5
parent 19efb3a15d
commit b086d5d22b
2 changed files with 14 additions and 3 deletions
+11 -2
View File
@@ -1,9 +1,9 @@
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"
import { createFileRoute } from "@tanstack/react-router"
import { createFileRoute, redirect } from "@tanstack/react-router"
import { KeyRound, Plus, Trash2 } from "lucide-react"
import { useState } from "react"
import { SecretsService } from "@/client"
import { SecretsService, UsersService } from "@/client"
import { Button } from "@/components/ui/button"
import {
Dialog,
@@ -19,6 +19,15 @@ import { handleError } from "@/utils"
export const Route = createFileRoute("/_layout/secrets")({
component: Secrets,
// `GET /secrets/` is a superuser's, as Admin is.
beforeLoad: async () => {
const user = await UsersService.readUserMe()
if (!user.is_superuser) {
throw redirect({
to: "/",
})
}
},
head: () => ({
meta: [
{