From 03b9423cebb0ffe5385435545e5e29d14ce6da75 Mon Sep 17 00:00:00 2001 From: Kenan KARAER Date: Wed, 3 Dec 2025 22:56:25 +0300 Subject: [PATCH] Feat: Fetch user email in Edit User page --- src/app/dashboard/settings/users/[id]/page.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/app/dashboard/settings/users/[id]/page.tsx b/src/app/dashboard/settings/users/[id]/page.tsx index 4f6e7d2..050b505 100644 --- a/src/app/dashboard/settings/users/[id]/page.tsx +++ b/src/app/dashboard/settings/users/[id]/page.tsx @@ -1,10 +1,12 @@ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { EditUserForm } from "./edit-user-form" import { createClient } from "@/lib/supabase/server" +import { createAdminClient } from "@/lib/supabase/admin" import { notFound } from "next/navigation" export default async function EditUserPage({ params }: { params: { id: string } }) { const supabase = await createClient() + const supabaseAdmin = await createAdminClient() // Fetch profile const { data: profile } = await supabase @@ -17,8 +19,14 @@ export default async function EditUserPage({ params }: { params: { id: string } notFound() } - // We can't easily get email from profiles if it's not stored there. - // But for editing, we mostly care about name and role. + // Fetch email from auth.users using admin client + let email = undefined + if (supabaseAdmin) { + const { data: { user }, error } = await supabaseAdmin.auth.admin.getUserById(params.id) + if (user) { + email = user.email + } + } return (
@@ -31,7 +39,7 @@ export default async function EditUserPage({ params }: { params: { id: string } id: profile.id, full_name: profile.full_name, role: profile.role, - email: undefined // Email is not in profiles table currently + email: email }} />