mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-10-28 20:23:09 +00:00
add admin checks for admin pages and run biome formating 🔨
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 11m8s
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 11m8s
This commit is contained in:
@@ -16,32 +16,31 @@ import { tryCatch } from "@/utils/tryCatch";
|
||||
// } from "@/components/ui/select";
|
||||
|
||||
export default async function UserUpdate({
|
||||
params,
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{
|
||||
userId: string;
|
||||
}>;
|
||||
params: Promise<{
|
||||
userId: string;
|
||||
}>;
|
||||
}) {
|
||||
const { userId } = await params;
|
||||
const session = await getServerSession(authOptions);
|
||||
if (!session?.user?.is_admin) return null
|
||||
const [error, user] = await tryCatch(getProfileById(userId));
|
||||
const { userId } = await params;
|
||||
const session = await getServerSession(authOptions);
|
||||
if (!session?.user?.is_admin) return redirect("/devices?page=1");
|
||||
const [error, user] = await tryCatch(getProfileById(userId));
|
||||
|
||||
if (error) {
|
||||
if (error.message === "UNAUTHORIZED") {
|
||||
redirect("/auth/signin");
|
||||
} else {
|
||||
return <ClientErrorMessage message={error.message} />;
|
||||
}
|
||||
}
|
||||
|
||||
if (error) {
|
||||
if (error.message === "UNAUTHORIZED") {
|
||||
redirect("/auth/signin");
|
||||
} else {
|
||||
return <ClientErrorMessage message={error.message} />;
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="flex items-center justify-between text-gray-500 text-2xl font-bold title-bg py-4 px-2 mb-4">
|
||||
<h3 className="text-sarLinkOrange text-2xl">Verify user</h3>
|
||||
</div>
|
||||
<UserUpdateForm user={user} />
|
||||
</div>
|
||||
);
|
||||
return (
|
||||
<div>
|
||||
<div className="flex items-center justify-between text-gray-500 text-2xl font-bold title-bg py-4 px-2 mb-4">
|
||||
<h3 className="text-sarLinkOrange text-2xl">Verify user</h3>
|
||||
</div>
|
||||
<UserUpdateForm user={user} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user