mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 12:31:14 -05:00
Implement RPC function for user emails
This commit is contained in:
@@ -19,6 +19,7 @@ interface UserProfile {
|
||||
id: string;
|
||||
user_id: string;
|
||||
username: string;
|
||||
email?: string;
|
||||
display_name?: string;
|
||||
avatar_url?: string;
|
||||
banned: boolean;
|
||||
@@ -49,17 +50,15 @@ export function ProfileManager() {
|
||||
try {
|
||||
setLoading(true);
|
||||
|
||||
// Fetch profiles with user roles
|
||||
// Fetch profiles with emails using secure RPC function
|
||||
const { data: profilesData, error: profilesError } = await supabase
|
||||
.from('profiles')
|
||||
.select('*')
|
||||
.order('created_at', { ascending: false });
|
||||
.rpc('get_users_with_emails');
|
||||
|
||||
if (profilesError) throw profilesError;
|
||||
|
||||
// Fetch roles for each user
|
||||
const profilesWithRoles = await Promise.all(
|
||||
profilesData.map(async (profile) => {
|
||||
(profilesData || []).map(async (profile) => {
|
||||
const { data: rolesData } = await supabase
|
||||
.from('user_roles')
|
||||
.select('role')
|
||||
@@ -453,7 +452,7 @@ export function ProfileManager() {
|
||||
targetUser={{
|
||||
userId: deletionTarget.user_id,
|
||||
username: deletionTarget.username,
|
||||
email: '', // Email not available in profile data
|
||||
email: deletionTarget.email || 'Email not found',
|
||||
displayName: deletionTarget.display_name || undefined,
|
||||
roles: deletionTarget.roles
|
||||
}}
|
||||
|
||||
@@ -4631,6 +4631,19 @@ export type Database = {
|
||||
Args: { _user_id: string }
|
||||
Returns: Json
|
||||
}
|
||||
get_users_with_emails: {
|
||||
Args: never
|
||||
Returns: {
|
||||
avatar_url: string
|
||||
banned: boolean
|
||||
created_at: string
|
||||
display_name: string
|
||||
email: string
|
||||
id: string
|
||||
user_id: string
|
||||
username: string
|
||||
}[]
|
||||
}
|
||||
get_version_diff: {
|
||||
Args: {
|
||||
p_entity_type: string
|
||||
|
||||
Reference in New Issue
Block a user