Skip to content

Commit

Permalink
fix set user role
Browse files Browse the repository at this point in the history
  • Loading branch information
Anchel123 committed Feb 5, 2025
1 parent 3e79d80 commit 07bd980
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/api/user/[user]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export async function PATCH(req: NextRequest, { params }: { params: Promise<{ us
}

const { user: username } = await params
const role = ROLE.get(req.nextUrl.searchParams.get("role") || "")
const role = ROLE.get(req.nextUrl.searchParams.get("userRole") || "")
try {
if (!role) throw new Error("Role is missing")

Expand Down
2 changes: 1 addition & 1 deletion app/settings/users/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function Users() {
const { data: session } = useSession()

const handleSetRole = async (username: string, role: string, oldRole?: string) => {
const result = await securedFetch(`api/user/${prepareArg(username)}`, {
const result = await securedFetch(`api/user/${prepareArg(username)}?userRole=${role}`, {
method: 'PATCH'
}, session?.user?.role, toast)

Expand Down

0 comments on commit 07bd980

Please sign in to comment.